Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162import type { DiagnosticCode } from './types.js';
export type ErrorCode = DiagnosticCode | (string & {});
export class AtpError extends Error { public readonly code: ErrorCode; public readonly status?: number | undefined; public readonly retryAfterMs?: number | undefined; public readonly details?: unknown;
constructor(message: string, code: ErrorCode = 'NetworkError', status?: number, retryAfterMs?: number, details?: unknown) { super(message); this.name = 'AtpError'; this.code = code; this.status = status; this.retryAfterMs = retryAfterMs; this.details = details; }}
export class NetworkError extends AtpError { constructor(message: string, status?: number, details?: unknown) { super(message, 'NetworkError', status, undefined, details); this.name = 'NetworkError'; }}
export class RateLimitError extends AtpError { constructor(message: string, retryAfterMs?: number, status: number = 429) { super(message, 'RateLimitHit', status, retryAfterMs); this.name = 'RateLimitError'; }}
export class CircuitOpenError extends AtpError { constructor(origin: string) { super(`Circuit breaker is OPEN for origin: ${origin}`, 'breakerOpen'); this.name = 'CircuitOpenError'; }}
export class AuthError extends AtpError { constructor(message: string, status: number = 401) { super(message, 'sessionDegraded', status); this.name = 'AuthError'; }}
export class NotFoundError extends AtpError { constructor(message: string) { super(message, 'feedDeleted', 404); this.name = 'NotFoundError'; }}
export class BudgetExceededError extends AtpError { constructor(message: string = 'Request budget exceeded for this stage') { super(message, 'BudgetExhausted'); this.name = 'BudgetExceededError'; }}