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:
npm
npx croct@latest use template.json5Properties
These are the supported properties:
- namestring
The action identifier. Always fail for this action.
- messagestring
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.
- links(optional)Array<object>