Skip to content

DefinitionError ​

The error that build(), getFieldTree(), getLayout() and getVisibility() throw for a definition with issues. It lists all of them.

ts
class DefinitionError extends Error {
  readonly issues: readonly DefinitionIssue[]
}

Explanation ​

Its message lists every issue with its path, one per line. Its issues are the issues validate() gives. Check for it with instanceof.

Example ​

ts
try {
  builder.build({
    version: '1',
    fields: [{ name: 'email', type: 'emial' }],
  })
} catch (error) {
  if (error instanceof DefinitionError) {
    console.log(error.issues) // every issue, as validate() gives them
  }
}

Guides ​

Types ​