/** * Hub Protocol REST API error class. * Thrown when the server returns a non-2xx response. */ export class HubApiError extends Error { constructor( message: string, public readonly statusCode: number, public readonly body?: unknown ) { super(message); this.name = "HubApiError"; } get isUnauthorized(): boolean { return this.statusCode === 401; } get isForbidden(): boolean { return this.statusCode === 403; } get isNotFound(): boolean { return this.statusCode === 404; } get isServerError(): boolean { return this.statusCode >= 500; } }