1 | import express = require("express");
|
2 |
|
3 | /**
|
4 | * Create new middleware to handle errors and respond with content negotiation.
|
5 | */
|
6 | declare function errorHandler(options?: errorHandler.Options): express.ErrorRequestHandler;
|
7 |
|
8 | declare namespace errorHandler {
|
9 | interface LoggingCallback {
|
10 | (err: Error, str: string, req: express.Request, res: express.Response): void;
|
11 | }
|
12 |
|
13 | interface Options {
|
14 | /**
|
15 | * Provide a function to be called with the error and a string representation of the erro
|
16 | * Defaults to true.
|
17 | *
|
18 | * Possible values:
|
19 | * true : Log errors using console.error(str).
|
20 | * false : Only send the error back in the response.
|
21 | * A function : pass the error to a function for handling.
|
22 | */
|
23 | log: boolean | LoggingCallback;
|
24 | }
|
25 |
|
26 | /**
|
27 | * Template title, framework authors may override this value.
|
28 | */
|
29 | const title: string;
|
30 | }
|
31 |
|
32 | export = errorHandler;
|