/** * Error thrown when a response body is null */ export class ResponseBodyNullError extends Error { constructor() { super('Response body is null'); this.name = 'ResponseBodyNullError'; } } /** * Error thrown when an HTTP error occurs */ export class HTTPError extends Error { constructor(status: number, message: string) { super(`HTTP error! Status: ${status} - ${message}`); this.name = 'HTTPError'; } } /** * Error thrown when the maximum number of retries is hit in an exponential backoff */ export class ExponentialBackoffMaxRetriesHitError extends Error { constructor(errors: Array) { super('Exponential backoff: Max retries hit', { cause: errors }); this.name = 'ExponentialBackoffMaxRetriesHitError'; } } /** * Error thrown when the exponential backoff retries are stopped */ export class ExponentialBackoffStoppedRetriesError extends Error { constructor(reason: unknown) { // Convert the reason to an error if it is not an error const reasonError = reason instanceof Error ? reason : new Error(`${reason}`); super(`Exponential backoff was aborted: "${reasonError.message}"`, { cause: reasonError }); this.name = 'ExponentialBackoffStoppedRetriesError'; } }