Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / errorhandler / README.md
1 # errorhandler
2
3 [![NPM Version][npm-image]][npm-url]
4 [![NPM Downloads][downloads-image]][downloads-url]
5 [![Build Status][travis-image]][travis-url]
6 [![Test Coverage][coveralls-image]][coveralls-url]
7 [![Gratipay][gratipay-image]][gratipay-url]
8
9 Development-only error handler middleware.
10
11 This middleware is only intended to be used in a development environment, as
12 the _full error stack traces and internal details of any object passed to this
13 module_ will be sent back to the client when an error occurs.
14
15 When an object is provided to Express as an error, this module will display
16 as much about this object as possible, and will do so by using content negotiation
17 for the response between HTML, JSON, and plain text.
18
19   * When the object is a standard `Error` object, the string provided by the
20     `stack` property will be returned in HTML/text responses.
21   * When the object is a non-`Error` object, the result of
22     [util.inspect](https://nodejs.org/api/util.html#util_util_inspect_object_options)
23     will be returned in HTML/text responses.
24   * For JSON responses, the result will be an object with all enumerable properties
25     from the object in the response.
26
27 ## Install
28
29 ```sh
30 $ npm install errorhandler
31 ```
32
33 ## API
34
35 ```js
36 var errorhandler = require('errorhandler')
37 ```
38
39 ### errorhandler(options)
40
41 Create new middleware to handle errors and respond with content negotiation.
42
43 #### Options
44
45 Error handler accepts these properties in the options object.
46
47 ##### log
48
49 Provide a function to be called with the error and a string representation of
50 the error. Can be used to write the error to any desired location, or set to
51 `false` to only send the error back in the response. Called as
52 `log(err, str, req, res)` where `err` is the `Error` object, `str` is a string
53 representation of the error, `req` is the request object and `res` is the
54 response object (note, this function is invoked _after_ the response has been
55 written).
56
57 The default value for this option is `true` unless `process.env.NODE_ENV === 'test'`.
58
59 Possible values:
60
61   * `true`: Log errors using `console.error(str)`.
62   * `false`: Only send the error back in the response.
63   * A function: pass the error to a function for handling.
64
65 ## Examples
66
67 ### Simple example
68
69 Basic example of adding this middleware as the error handler only in development
70 with `connect` (`express` also can be used in this example).
71
72 ```js
73 var connect = require('connect')
74 var errorhandler = require('errorhandler')
75
76 var app = connect()
77
78 if (process.env.NODE_ENV === 'development') {
79   // only use in development
80   app.use(errorhandler())
81 }
82 ```
83
84 ### Custom output location
85
86 Sometimes you may want to output the errors to a different location than STDERR
87 during development, like a system notification, for example.
88
89 ```js
90 var connect = require('connect')
91 var errorhandler = require('errorhandler')
92 var notifier = require('node-notifier')
93
94 var app = connect()
95
96 if (process.env.NODE_ENV === 'development') {
97   // only use in development
98   app.use(errorhandler({log: errorNotification}))
99 }
100
101 function errorNotification(err, str, req) {
102   var title = 'Error in ' + req.method + ' ' + req.url
103
104   notifier.notify({
105     title: title,
106     message: str
107   })
108 }
109 ```
110
111 ## License
112
113 [MIT](LICENSE)
114
115 [npm-image]: https://img.shields.io/npm/v/errorhandler.svg
116 [npm-url]: https://npmjs.org/package/errorhandler
117 [travis-image]: https://img.shields.io/travis/expressjs/errorhandler/master.svg
118 [travis-url]: https://travis-ci.org/expressjs/errorhandler
119 [coveralls-image]: https://img.shields.io/coveralls/expressjs/errorhandler/master.svg
120 [coveralls-url]: https://coveralls.io/r/expressjs/errorhandler?branch=master
121 [downloads-image]: https://img.shields.io/npm/dm/errorhandler.svg
122 [downloads-url]: https://npmjs.org/package/errorhandler
123 [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg
124 [gratipay-url]: https://www.gratipay.com/dougwilson/