1 | // Type definitions for errorhandler 1.5
|
2 | // Project: https://github.com/expressjs/errorhandler
|
3 | // Definitions by: Santi Albo <https://github.com/santialbo>
|
4 | // Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 |
|
7 | import express = require('express');
|
8 |
|
9 | /**
|
10 | * Create new middleware to handle errors and respond with content negotiation.
|
11 | */
|
12 | declare function errorHandler(options?: errorHandler.Options): express.ErrorRequestHandler;
|
13 |
|
14 | declare namespace errorHandler {
|
15 | interface LoggingCallback {
|
16 | (err: Error, str: string, req: express.Request, res: express.Response): void;
|
17 | }
|
18 |
|
19 | interface Options {
|
20 | /**
|
21 | * Provide a function to be called with the error and a string representation of the erro
|
22 | * Defaults to true.
|
23 | *
|
24 | * Possible values:
|
25 | * true : Log errors using console.error(str).
|
26 | * false : Only send the error back in the response.
|
27 | * A function : pass the error to a function for handling.
|
28 | */
|
29 | log: boolean | LoggingCallback;
|
30 | }
|
31 |
|
32 | /**
|
33 | * Template title, framework authors may override this value.
|
34 | */
|
35 | const title: string;
|
36 | }
|
37 |
|
38 | export = errorHandler;
|