CatalogueEntry
interface| Package | @formscript/errors |
|---|---|
| Specification | 14 |
| Depends on | nothing — it is a leaf |
@formscript/errors
The error catalogue of §14 of the specification, and the diagnostic objects that carry it.
Every error a FormScript runtime reports has a stable, machine-readable code. The message text is not stable and must not be matched on; the code is.
The catalogue is generated
src/catalogue.generated.ts is produced from the specification's own §14 table
by scripts/generate-catalogue.ts. A test asserts that the generated file
matches the current specification, so the two cannot drift apart.
npm run generate:catalogue
Each entry carries its code, its message, its category — the class that decides when the error is reported — and any notes:
{
code: 'E-REF-01',
message: 'undefined reference',
category: 'semantic',
notes: '',
}
Diagnostics
import { diagnostic } from '@formscript/errors';
const d = diagnostic('E-REF-01', {
message: "unknown reference 'nmae'",
location: { line: 12, column: 5, file: 'application.forms' },
path: 'nmae',
context: { suggestions: ['name'] },
});
diagnostic fills the message from the catalogue when none is given, and
defaults the severity to error.
Suggestions
suggest and nearMisses use edit distance to propose likely intended names.
They power the suggestions and near_misses context fields, which a runtime
may show to the person who wrote the document.
Public API
17 exported symbols.
catalogueMessage
functiondiagnostic
function
Builds a diagnostic for a catalogue code. The code is the only required field; the message defaults to the catalogue's.
Diagnostic
interfaceDiagnosticContext
interfaceDiagnosticInit
interfaceeditDistance
re-exportERROR_CATALOGUE
constERROR_CODES
constErrorCategory
type
GENERATED FILE — do not edit. Source: FormScript-Language-Specification.md, section 14. Regenerate with: npm run generate:catalogue Verify with: npm test (pa…
ErrorCode
typeisErrorCode
functionnearMisses
re-exportSeverity
typeSourceLocation
interfacesuggest
re-exportSuggestionOptions
interface