Files
xo-cash-utils/source/template/errors.ts
T
2026-10-05 12:59:22 +00:00

33 lines
980 B
TypeScript

/* eslint-disable max-classes-per-file */
/**
* Thrown when the provided template does not satisfy the XOTemplate schema.
*/
export class TemplateInvalidError extends Error {
constructor(details: string) {
const message = `Template invalid: ${details}`;
super(message);
this.name = 'TemplateInvalidError';
}
}
/**
* Thrown when a string passed to `deserializeTemplate` cannot be parsed as JSON.
*/
export class TemplateJsonMalformedError extends Error {
constructor(reason: string) {
super(`Template JSON malformed, expected a valid JSON string: ${reason}`);
this.name = 'TemplateJsonMalformedError';
}
}
/**
* Thrown when `serializeTemplate` fails to produce a JSON string from the template.
*/
export class TemplateSerializationFailedError extends Error {
constructor(reason: string) {
super(`Template serialization failed: ${reason}`);
this.name = 'TemplateSerializationFailedError';
}
}