Skip to content

Custom errors

When a user action encounters an error, a generic message, such as “The action failed to execute,” is displayed. This message, while informative, may not provide users with enough context or guidance. To improve the user experience, you can throw a custom error message that is more specific to the situation.

Creating a custom error

To override the default error message, you can throw a CustomError with a tailored message, providing additional clarity for the user:

throw new CustomError("Custom error message");
By providing a unique message, users receive more relevant information, potentially helping them understand the cause of the issue and guiding them on how to resolve it.

Text expressions in custom errors

You can make custom error messages dynamic and more user-specific by embedding data using Text Expressions. This approach allows you to personalize error messages based on variables or context from within the application:

throw new CustomError("Hello {{F['clientName']}}! An error was thrown.");
In this example, the error message includes the client’s name, creating a more tailored experience. Text expressions can pull data from fields, making your error messages highly flexible and customized.