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 | 1x 23x 23x 23x 23x 23x 23x 23x 1x 1x 4x 4x 4x 1x 1x 1x 5x 5x 5x 1x 1x 1x 4x 4x 4x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x | /**
* Lightweight error classes for opensip-tools.
* Replaces @opensip/foundation/errors — no external dependencies.
*/
export interface ToolErrorOptions extends ErrorOptions {
code?: string;
[key: string]: unknown;
}
export class ToolError extends Error {
readonly code: string;
constructor(message: string, code: string, options?: ToolErrorOptions) {
super(message, options);
this.name = 'ToolError';
this.code = code;
}
}
export class ValidationError extends ToolError {
constructor(message: string, options?: ToolErrorOptions) {
super(message, options?.code ?? 'VALIDATION_ERROR', options);
this.name = 'ValidationError';
}
}
export class NotFoundError extends ToolError {
constructor(message: string, options?: ToolErrorOptions) {
super(message, options?.code ?? 'NOT_FOUND', options);
this.name = 'NotFoundError';
}
}
export class SystemError extends ToolError {
constructor(message: string, options?: ToolErrorOptions) {
super(message, options?.code ?? 'SYSTEM_ERROR', options);
this.name = 'SystemError';
}
}
export class TimeoutError extends ToolError {
readonly timeoutMs?: number;
constructor(message: string, timeoutOrOptions?: number | ToolErrorOptions) {
const options = typeof timeoutOrOptions === 'number' ? undefined : timeoutOrOptions;
super(message, options?.code ?? 'TIMEOUT', options);
this.name = 'TimeoutError';
this.timeoutMs = typeof timeoutOrOptions === 'number' ? timeoutOrOptions : undefined;
}
}
|