ValidationError
On this page

ValidationError

Class in Diagnostics

Thrown by validate when a module fails one of the structural rules every emit depends on.

import { ValidationError } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

class ValidationError extends TypeShadeError

Description

Subclasses TypeShadeError and carries code SD0020, so an instanceof TypeShadeError handler catches it and a handler that switches on code routes it.

Catch this class for ValidationError.diagnostics: validate() collects every error-severity diagnostic before throwing, so one throw reports every failure in the module. .message renders the same list as text; the array is the form to present in a UI or a test report.

Examples

Example

import { validate, ValidationError } from 'typeshade'
try {
validate(MODULE)
} catch (e) {
if (e instanceof ValidationError) for (const d of e.diagnostics) report(d.ruleId, d.message)
else throw e
}

Constructor

new ValidationError(diags: readonly Diagnostic[])

Instance properties

diagnosticsread only readonly Diagnostic[]

Every error-severity diagnostic that caused the failure, in the order the rules reported them.

In the guide

See also

Source

src/core/passes/validate.ts, line 59, at commit 26de7be8

Edit this page Report a problem