File size: 832 Bytes
0ed8124
 
 
3fd9ca4
0ed8124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
export interface WebGpuDeviceLostDetails {
  recoverable: true;
  nextAction: 'reload-model';
  stage: 'load' | 'generate' | 'score-sequence' | 'backend-report';
  modelId: string;
  cpuFallbackAvailable: boolean;
  signal: {
    line: string;
    reason: number | null;
    message: string | null;
  };
}

export class EngineRuntimeError extends Error {
  readonly code: string;
  readonly details?: unknown;

  constructor(code: string, message: string, details?: unknown) {
    super(message);
    this.name = 'EngineRuntimeError';
    this.code = code;
    this.details = details;
  }
}

export function abortError(): DOMException {
  return new DOMException('The engine operation was aborted.', 'AbortError');
}

export function throwIfAborted(signal: AbortSignal): void {
  if (signal.aborted) {
    throw abortError();
  }
}