56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
/**
|
|
* Typed failures of the engine. The app maps the kinds to its messages; no
|
|
* message here echoes untrusted input.
|
|
*/
|
|
|
|
export type ArchiveReadErrorKind =
|
|
| 'invalid_pdf'
|
|
| 'no_attachment'
|
|
| 'attachment_stripped'
|
|
| 'incompatible_version'
|
|
|
|
export class ArchiveReadError extends Error {
|
|
constructor(
|
|
public readonly kind: ArchiveReadErrorKind,
|
|
/** The report version found, for `incompatible_version`. */
|
|
public readonly foundVersion?: number | null,
|
|
) {
|
|
super(kind)
|
|
this.name = 'ArchiveReadError'
|
|
}
|
|
}
|
|
|
|
export type ArchiveExportErrorKind =
|
|
| 'snapshot_invalid'
|
|
| 'snapshot_too_large'
|
|
| 'sheet_mismatch'
|
|
| 'too_many_pages'
|
|
/** The branding or the label set fails its schema (URLs included). */
|
|
| 'branding_invalid'
|
|
|
|
export class ArchiveExportError extends Error {
|
|
constructor(
|
|
public readonly kind: ArchiveExportErrorKind,
|
|
detail = '',
|
|
) {
|
|
super(detail ? `${kind}: ${detail}` : kind)
|
|
this.name = 'ArchiveExportError'
|
|
}
|
|
}
|
|
|
|
export type SvgRejection =
|
|
| 'doctype'
|
|
| 'malformed'
|
|
| 'not_svg'
|
|
| 'too_many_elements'
|
|
| 'too_deep'
|
|
| 'too_many_uses'
|
|
|
|
/** An SVG text the sanitiser refuses outright (STEP6 §15). */
|
|
export class SvgRejectedError extends Error {
|
|
constructor(public readonly reason: SvgRejection) {
|
|
super(`svg rejected: ${reason}`)
|
|
this.name = 'SvgRejectedError'
|
|
}
|
|
}
|