createAuthor(request.body) .then(author => { response.json(HTTP.CREATED, {id: author._id}); return next(); }).catch(error => { response.json(HTTP.INTERNAL_SERVER_ERROR, {error}); return next(error); });
fs.readFile(`./${file}`, (error, data) => { if (error) { res.writeHead(httpStatus.INTERNAL_SERVER_ERROR, contentTypes.html); res.end("There was an error serving content!"); } res.end(data); });
/** * Takes care of any uncaught error that was not handled specifically for * a specific app instance. * @param app Express app instance */ function attachWithApp(app) { app.use((err, req, res, next) => { if (!err) { next(); } logger.log('Error: %s %O', err.message, err.stack); res.status(statusCodes.INTERNAL_SERVER_ERROR).send({ 'message': 'Internal Server Error' }); }); }
findAllAuthors() .then(authors => { response.json({authors}); return next(); }).catch(error => { response.json(HTTP.INTERNAL_SERVER_ERROR, {error}); return next(error); });
expect(responseStub.json.calledWith(HTTP.INTERNAL_SERVER_ERROR, {error: errorStub})).to.ok(); done(); });
logger.logFullError(err, req.signature || `${req.method} ${req.url}`) const errorResponse = {} const status = err.isJoi ? HttpStatus.BAD_REQUEST : (err.httpStatus || _.get(err, 'response.status') || HttpStatus.INTERNAL_SERVER_ERROR) if (err.message && status !== HttpStatus.INTERNAL_SERVER_ERROR) { errorResponse.message = err.message } else {
expect(responseStub.json.calledWith(HTTP.INTERNAL_SERVER_ERROR, {error: errorStub})).to.ok(); done(); });