http-micro
Version:
Micro-framework on top of node's http module
44 lines (43 loc) • 1.68 kB
TypeScript
/// <reference types="http-errors" />
/// <reference types="node" />
import * as http from "http";
import * as httpError from "http-errors";
export declare const InnerErrorKey = "cause";
export declare const HttpErrorStatusCodeKey = "statusCode";
export declare function getErrorInfo(err: Error): string;
/**
* Check if the status is a 4xx or 5xx status code.
*/
export declare function isHttpErrorStatusCode(code: number): boolean;
/**
* Check if the status is a 4xx status code.
*/
export declare function isHttpClientErrorStatusCode(code: number): boolean;
/**
* Check if the 'statusCode' property of error object
* is a valid 4xx or 5xx status code. Return the code
* if it is, or else return 500.
*/
export declare function getHttpErrorStatusCode(err: Error): any;
/**
* Check if an error object is a valid http error, by
* testing if 'statusCode' property of the error object
* is a valid 4xx or 5xx status code.
*/
export declare function isHttpError(err: Error): boolean;
/**
* Wrap an error into another error using the defacto
* 'cause' property.
*/
export declare function wrapError(targetError: Error, originalError: Error, linkMessage?: boolean): void;
export declare function intoHttpError(err: Error, code?: number, forceCode?: boolean): httpError.HttpError;
export declare function errorToResponse(err: Error, res: http.ServerResponse): void;
export declare function makeNestedErrorIterable(err: Error): {
[Symbol.iterator](): {
next: () => {
done: boolean;
value: Error;
};
};
};
export declare function recurseErrorInfo(err: Error): IterableIterator<string>;