返回 html-video
errors.ts
根目录 / packages / core / src / errors.ts
1 /**
2 * Stable error codes per RFC-01 + RFC-05.
3 */
4
5 export type ErrorCode =
6 | 'engine-not-installed'
7 | 'engine-not-registered'
8 | 'template-invalid'
9 | 'template-not-found'
10 | 'render-failed'
11 | 'render-timeout'
12 | 'output-corrupt'
13 | 'disk-full'
14 | 'cancelled'
15 | 'asset-not-found'
16 | 'project-not-found'
17 | 'invalid-input';
18
19 export class HtmlVideoError extends Error {
20 override readonly name = 'HtmlVideoError';
21 constructor(
22 public readonly code: ErrorCode,
23 message: string,
24 public readonly retryable = false,
25 public readonly context: Record<string, unknown> = {},
26 ) {
27 super(message);
28 }
29
30 toJSON(): Record<string, unknown> {
31 return {
32 name: this.name,
33 code: this.code,
34 message: this.message,
35 retryable: this.retryable,
36 context: this.context,
37 };
38 }
39 }
40
40 lines TYPESCRIPT