Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 972 Bytes

errorHandler.md

File metadata and controls

28 lines (20 loc) · 972 Bytes

Error Handler

The errorHandler middleware responds to exceptions passed or caught from within middleware above it, according to the options shown below.

connect.createServer(
    function(req, res, next){
	    throw new Error('ahhhh!');
    },
	connect.errorHandler({ dumpExceptions: true })
);

By default the response of errorHandler is 500 'Internal Server Error'. If showStack is true, then Connect decides how to respond based on the Accept request header:

text/html         Outputs an html version of the stack trace
application/json  Outputs json { 'error': { 'message': ... }}
otherwise         Outputs plain text stack trace

Options

showMessage     Show the exception message only  
showStack       Show the exception message and stack trace
dumpExceptions  Output exception stack traces to stderr (does not re-throw)

Environment Variables

--showErrorMessage
--showErrorStack
--dumpExceptions