Skip to main content

betaThis is a new capability. Help us improve it and give your feedback on Slack.

Form definition errors

When a form definition cannot be used, the plugin throws an error that extends InvalidFormDefinitionError. Check for this base class to tell a problem with the form apart from a problem with your service, for example to show the form author an error page in preview.

import { InvalidFormDefinitionError } from '@defra/forms-engine-plugin/engine/errors.js'
if (err instanceof InvalidFormDefinitionError) {
// The form definition is invalid. err.message describes the problem.
}
ErrorThrown whenExtra properties
SchemaValidationErrorThe definition fails schema validationcause: the Joi ValidationError with its details
ConditionBuildErrorA condition cannot be built, for example because it refers to the wrong componentconditionName
UnknownPageControllerErrorA page names a controller that is not built in or registered in controllerscontrollerName
UnknownComponentTypeErrorA component has a type with no implementationcomponentType

The error messages describe only the form, so that you can show them to form authors.