-
Notifications
You must be signed in to change notification settings - Fork 16
/
errorhandler.express.txt
22 lines (17 loc) · 1.94 KB
/
errorhandler.express.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ERRORHANDLER
VERSION ==> #1.5.1
ERRORHANDLER([OPTS]) #Express MIDWR error handler (to put at end) that:
# - sends ERROR.stack as response
# - as HTML, JSON or text/plain according to Accept [C]
# - sets RES.statusCode = ERROR.status[Code]
# - 3**, 2**, 1** -> 500
# - performs OPTS.log(ERROR, ERROR.message, REQ, RES)
# - can be true (def), i.e. console.error()
# - can be false (def is NODE_ENV 'test')
# - sets X-Content-Type-Options: nosniff [S]
#Should only be used in development:
# if ( app.get( "env" ) == "development" ) {
# app.use( ERRORHANDLER() )
# }