nyro
Version:
A simple and effective promise-based HTTP & HTTP/2 request library that supports all HTTP methods.
55 lines (54 loc) • 1.73 kB
TypeScript
/**
* Interface representing the options for handling errors.
*
* @interface ErrorHandlerOptions
*
* @property {string} message - The error message to be displayed.
* @property {any} [requestOptions] - Optional request options associated with the error.
* @property {number} statusCode - The HTTP status code associated with the error.
* @property {string} name - The name of the error.
* @property {Error} [error] - Optional original error object.
*/
export interface NyroErrorInterface {
message: string;
requestOptions?: any;
response?: any;
request?: any;
statusCode: number;
name: string;
error?: Error;
body?: any;
}
/**
* Interface representing the error response object.
*
* @interface NyroErrorResponse
*
* @property {string} message - The error message to be displayed.
* @property {any} [requestOptions] - Optional request options associated with the error.
* @property {string} [statusText] - The status text associated with the error.
* @property {number} statusCode - The HTTP status code associated with the error.
* @property {string} name - The name of the error.
* @property {Error} [error] - Optional original error object.
*/
export interface NyroErrorResponse {
message: string;
requestOptions?: any;
request?: any;
response?: any;
statusText?: string;
statusCode: number;
name: string;
error?: Error;
body?: any;
}
export declare function isNyroError(error: any): error is ErrorHandler;
export default class ErrorHandler extends Error {
requestOptions?: any;
statusText?: string;
statusCode: number;
response?: any;
request?: any;
body?: any;
constructor(errorHandlerOptions: NyroErrorInterface);
}