@types/errorhandler
Version:
TypeScript definitions for errorhandler
52 lines (41 loc) • 1.7 kB
Markdown
# Installation
> `npm install --save @types/errorhandler`
# Summary
This package contains type definitions for errorhandler (https://github.com/expressjs/errorhandler).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/errorhandler.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/errorhandler/index.d.ts)
````ts
import express = require("express");
/**
* Create new middleware to handle errors and respond with content negotiation.
*/
declare function errorHandler(options?: errorHandler.Options): express.ErrorRequestHandler;
declare namespace errorHandler {
interface LoggingCallback {
(err: Error, str: string, req: express.Request, res: express.Response): void;
}
interface Options {
/**
* Provide a function to be called with the error and a string representation of the erro
* Defaults to true.
*
* Possible values:
* true : Log errors using console.error(str).
* false : Only send the error back in the response.
* A function : pass the error to a function for handling.
*/
log: boolean | LoggingCallback;
}
/**
* Template title, framework authors may override this value.
*/
const title: string;
}
export = errorHandler;
````
### Additional Details
* Last updated: Mon, 06 Nov 2023 22:41:05 GMT
* Dependencies: [@types/express](https://npmjs.com/package/@types/express)
# Credits
These definitions were written by [Santi Albo](https://github.com/santialbo), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).