autumn-js
Version:
Autumn JS Library
30 lines (27 loc) • 626 B
TypeScript
interface ErrorResponse {
message: string;
code: string;
}
declare class AutumnError extends Error {
readonly message: string;
readonly code: string;
constructor(response: ErrorResponse);
static fromError(error: any): AutumnError;
toString(): string;
toJSON(): {
message: string;
code: string;
};
}
type Success<T> = {
data: T;
error: null;
statusCode?: number;
};
type Failure<E> = {
data: null;
error: E;
statusCode?: number;
};
type Result<T, E> = Success<T> | Failure<E>;
export { AutumnError as A, type ErrorResponse as E, type Result as R };