driver.js
function errors() {
        // handling 404 errors from config.express['404_redirect'] property
        if (config['404_redirect']) {
            server.use(function (req, res, next) {
                res.status(302)
                res.writeHead(302, { 'Location': config['404_redirect'] })
                res.end()
            })
        } else {
            server.use(function (req, res, next) {
                res.status(404).send({ message: 'not found' })
            })
        }

        if (errorHandlers.length) {
            for (let eh of errorHandlers) {
                server.use(wrapper(eh))
            }
        }

        //Default error handler
        server.use((err, req, res, next) => {
            if (!config.silent && !errorHandlers.length)
                app.drivers.logger.error('Unhandled server error', err)
            res.status(500)
               .json({
                   message: err.message,
                   stack: process.env.NODE_ENV === 'production' ? undefined : err.stack
               })
        })
    }
function errors() {
        // handling 404 errors from config.express['404_redirect'] property
        if (config['404_redirect']) {
            server.use(function (req, res, next) {
                res.status(302)
                res.writeHead(302, { 'Location': config['404_redirect'] })
                res.end()
            })
        } else {
            server.use(function (req, res, next) {
                res.status(404).send({ message: 'not found' })
            })
        }

        if (errorHandlers.length) {
            for (let eh of errorHandlers) {
                server.use(wrapper(eh))
            }
        }

        //Default error handler
        server.use((err, req, res, next) => {
            if (!config.silent && !errorHandlers.length)
                app.drivers.logger.error('Unhandled server error', err)
            res.status(500)
               .json({
                   message: err.message,
                   stack: process.env.NODE_ENV === 'production' ? undefined : err.stack
               })
        })
    }
function errors ( ) { // handling 404 errors from config.express['404_redirect'] property if ( config [ '404_redirect' ] ) { server . use ( function ( req , res , next ) { res . status ( 302 ) res . writeHead ( 302 , { 'Location' : config [ '404_redirect' ] } ) res . end ( ) } ) } else { server . use ( function ( req , res , next ) { res . status ( 404 ) . send ( { message : 'not found' } ) } ) } if ( errorHandlers . length ) { for ( let eh of errorHandlers ) { server . use ( wrapper ( eh ) ) } } //Default error handler server . use ( ( err , req , res , next ) => { if ( ! config . silent && ! errorHandlers . length ) app . drivers . logger . error ( 'Unhandled server error' , err ) res . status ( 500 ) . json ( { message : err . message , stack : process . env . NODE_ENV === 'production' ? undefined : err . stack } ) } ) }
Register error handlers
Register error handlers