UNPKG

trainingpeaks-sdk

Version:
42 lines 2.35 kB
import { SDKError } from '../../domain/errors/sdk-error.js'; import type { HttpError as IHttpError, HttpErrorContext, HttpErrorResponse } from '../../domain/types/http-error.js'; export type { HttpErrorContext, HttpErrorResponse, } from '../../domain/types/http-error.js'; export declare class HttpError extends SDKError implements IHttpError { readonly status: number; readonly statusText: string; readonly url?: string; readonly method?: string; readonly requestId?: string; readonly code: string; constructor(message: string, code: string, context: HttpErrorContext, options?: { cause?: unknown; }); } export declare const createHttpError: (response: HttpErrorResponse, context?: { url?: string; method?: string; requestData?: unknown; requestId?: string; }, cause?: unknown) => HttpError; export declare const isHttpError: (error: unknown) => error is HttpError; export declare const isClientError: (error: unknown) => boolean; export declare const isServerError: (error: unknown) => boolean; export declare const isRetryableError: (error: unknown) => boolean; import type { HttpResponse } from '../../application/index.js'; export type ErrorRequestContext = { url: string; method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; requestData?: unknown; requestId?: string; }; export declare const throwHttpErrorFromResponse: <T>(response: HttpResponse<T>, operation: string, context: ErrorRequestContext) => never; export declare const throwValidationError: (message: string, context: ErrorRequestContext) => never; export declare const throwMissingDataError: (message: string, context: ErrorRequestContext) => never; export declare const throwServerError: (error: unknown, fallbackMessage: string, context: ErrorRequestContext) => never; export declare const throwAuthError: (message: string, context: ErrorRequestContext) => never; export declare const throwCookieNotFoundError: (cookieName: string, context: ErrorRequestContext) => never; export declare const throwTokenExpiredError: (context: ErrorRequestContext) => never; export declare const handleRepositoryError: (error: unknown, operation: string, context: ErrorRequestContext, logger: { error: (message: string, details?: unknown) => void; }, params?: unknown) => never; //# sourceMappingURL=http-errors.d.ts.map