magicbell
Version:
MagicBell API wrapper
83 lines (82 loc) • 2.19 kB
TypeScript
export declare function createError(rawError: ErrorConfig): AuthenticationError | InvalidRequestError | APIError | RateLimitError | IdempotencyError | NotFoundError | UserInputError | UnknownError;
type ErrorConfig = {
name: string;
type?: string;
code?: string;
docs_url?: string;
help_link?: string;
status?: number;
statusText?: string;
responseBody?: unknown;
message: string;
suggestion?: string;
stack?: string;
};
/**
* BaseError is the base error from which all other more specific errors derive.
* Specifically for errors returned from REST API.
*/
export declare class MagicBellError extends Error {
/**
* The name of the error.
*/
name: string;
/**
* The error message returned by the REST API.
*/
message: string;
/**
* The type of the error.
*/
type?: string;
/**
* The URL to the documentation for the error.
*/
docsUrl?: string;
/**
* The error code returned by the REST API.
*/
code?: string;
/**
* The HTTP status code returned by the REST API.
*/
status?: number;
/**
* The HTTP status text returned by the REST API.
*/
statusText?: string;
/**
* A suggestion on how to fix the error.
*/
suggestion?: string;
/**
* The raw response body returned by the REST API.
*/
responseBody?: unknown;
/**
* @deprecated - use docsUrl instead
*/
get docs_url(): string;
constructor(raw: ErrorConfig);
}
export declare class InvalidRequestError extends MagicBellError {
}
export declare class UserInputError extends MagicBellError {
}
export declare class APIError extends MagicBellError {
}
export declare class AuthenticationError extends MagicBellError {
}
export declare class PermissionError extends MagicBellError {
}
export declare class RateLimitError extends MagicBellError {
}
export declare class ConnectionError extends MagicBellError {
}
export declare class IdempotencyError extends MagicBellError {
}
export declare class UnknownError extends MagicBellError {
}
export declare class NotFoundError extends MagicBellError {
}
export {};