fail

Learn how to terminate execution with an error.

This action terminates template execution with an error message.

It works well as an early guard to abort when a required condition is not met. For example, you can stop execution with a clear message and helpful links when no supported framework is detected in the current directory.

Example

The following template checks for a Next.js project and fails with a helpful message if none is found:

template.json5
{  "$schema": "https://schema.croct.com/json/v1/template.json",  "title": "Next.js check",  "description": "Fails if no Next.js project is detected.",  "actions": [    {      "name": "test",      "condition": "${project.platform === 'unknown'}",      "then": [        {          "name": "fail",          "title": "Project not found",          "message": "This template requires a Next.js project.",          "details": [            "No supported framework detected in the current directory."          ],          "suggestions": [            "Navigate to your project directory and try again."          ],          "links": [            {              "label": "Getting started",              "url": "https://croct.com/docs/getting-started"            }          ]        }      ]    }  ]}

To apply this template, run:

npx croct@latest use template.json5

Properties

These are the supported properties:

name
string

The action identifier. Always fail for this action.

message
string

The error message to display.

title(optional)
string

A short title for the error.

details(optional)
Array<string>

A list of details providing additional context about the error.

suggestions(optional)
Array<string>

A list of suggestions to help the user resolve the issue.

A list of links with additional information.