@unito/integration-sdk
Version:
Integration SDK
79 lines (78 loc) • 3.05 kB
TypeScript
export interface HttpErrorOptions {
/** The minimum number of seconds to wait before retrying the request. */
retryAfter?: number;
/** The raw response headers from the provider, kept so error/log handling can extract further signals. */
responseHeaders?: Record<string, string>;
}
/**
* Error class meant to be returned by integrations in case of exceptions. These errors will be caught and handled
* appropriately. Any other error would result in an unhandled server error accompanied by a 500 status code.
*
* @field message - The error message
* @field status - The HTTP status code to return
* @field retryAfter - The minimum number of seconds to wait before retrying the request.
* @field responseHeaders - The raw response headers from the provider, when the error came from a provider response.
*/
export declare class HttpError extends Error {
readonly status: number;
retryAfter: number | undefined;
responseHeaders: Record<string, string> | undefined;
constructor(message: string, status: number, options?: HttpErrorOptions);
}
/**
* Used to generate a 400 Bad Request. Usually used when something is missing to properly handle the request.
*/
export declare class BadRequestError extends HttpError {
constructor(message?: string);
}
/**
* Used to generate a 401 Unauthorized. Usually used when the credentials are missing or invalid.
*/
export declare class UnauthorizedError extends HttpError {
constructor(message?: string);
}
/**
* Used to generate a 403 Forbidden. Usually used when user lacks sufficient permission to access a ressource.
*/
export declare class ForbiddenError extends HttpError {
constructor(message?: string);
}
/**
* Used to generate a 404 Not Found. Usually used when the requested `Item` is not found.
*/
export declare class NotFoundError extends HttpError {
constructor(message?: string);
}
/**
* Used to generate a 408 Timeout Error. Usually used when the call length exceeds the received Operation Deadline.
*/
export declare class TimeoutError extends HttpError {
constructor(message?: string);
}
/**
* Used to generate a 410 Resource Gone.
*
* @deprecated Use ProviderInstanceLockedError instead when the provider instance is locked or unavailable.
*/
export declare class ResourceGoneError extends HttpError {
constructor(message?: string);
}
/**
* Used to generate a 422 Unprocessable Entity. Usually used when an operation is invalid.
*/
export declare class UnprocessableEntityError extends HttpError {
constructor(message?: string);
}
/**
* Used to generate a 423 Provider Instance Locked.
*/
export declare class ProviderInstanceLockedError extends HttpError {
constructor(message?: string, options?: HttpErrorOptions);
}
/**
* Used to generate a 429 Rate Limit Exceeded. Usually used when an operation triggers or would trigger a rate limit
* error on the provider's side.
*/
export declare class RateLimitExceededError extends HttpError {
constructor(message?: string, options?: HttpErrorOptions);
}