Customizable Error Messages
Chevrotain allows users to customize both the parser and lexer error messages. This can be accomplished by implementing the following interfaces:
See executable examples:
In addition it is also possible to directly provide strings values to be used in errors for specific parsing DSL methods, for example:
$.RULE("myStatement", () => {
// ...
$.CONSUME(SemiColon, {
ERR_MSG: "expecting semiColon at end of myStatement",
});
});
The ERR_MSG config property is available for the following DSL methods: