All files / embed-code-core/src errors.ts

100% Statements 18/18
100% Branches 0/0
100% Functions 8/8
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                  21x 21x           2x 2x             5x   5x 5x           2x 2x             3x   3x 3x           2x 2x           2x 2x           2x 2x      
/**
 * Error classes for embed-code-ts.
 *
 * Provides a typed error hierarchy so consumers can distinguish
 * between different failure modes at runtime.
 */
 
export class EmbedCodeError extends Error {
  constructor(message: string, options?: { cause?: Error }) {
    super(message, options);
    this.name = 'EmbedCodeError';
  }
}
 
export class ModelNotFoundError extends EmbedCodeError {
  constructor(message: string) {
    super(message);
    this.name = 'ModelNotFoundError';
  }
}
 
export class DownloadError extends EmbedCodeError {
  constructor(
    message: string,
    public readonly statusCode?: number,
  ) {
    super(message);
    this.name = 'DownloadError';
  }
}
 
export class ChecksumMismatchError extends EmbedCodeError {
  constructor(message: string) {
    super(message);
    this.name = 'ChecksumMismatchError';
  }
}
 
export class ProxyAuthError extends EmbedCodeError {
  constructor(
    message: string,
    public readonly statusCode: number,
  ) {
    super(message);
    this.name = 'ProxyAuthError';
  }
}
 
export class InferenceError extends EmbedCodeError {
  constructor(message: string, cause?: Error) {
    super(message, { cause });
    this.name = 'InferenceError';
  }
}
 
export class TokenizationError extends EmbedCodeError {
  constructor(message: string, options?: { cause?: Error }) {
    super(message, options);
    this.name = 'TokenizationError';
  }
}
 
export class ModelNotCompiledError extends EmbedCodeError {
  constructor(message: string) {
    super(message);
    this.name = 'ModelNotCompiledError';
  }
}