error.js
* @module greppy/helper/controller/error
* @author Hermann Mayer <hermann.mayer92@gmail.com>
* Format the given error to print in an uniform way.
* @param {Object} err - Error object
ErrorHelper.prototype.format = function(err)
str += self.format(item) + '\n';
if ('object' === typeof err) {
cur = JSON.stringify(err, null, ' ');
* Log the error with the corresponding request.
* @param {Object} req - Request object
* @param {Object} err - Error object
ErrorHelper.prototype.log = function(req, err)
'Error occured on ' + req.url.green.bold + ' - Details:\n' +
'\nStack trace: ' + (err.stack
* Log the error and respond with an internal server
* @param {Object} req - Request object
* @param {Object} res - Response object
* @param {Object} err - Error object
ErrorHelper.prototype.respond500 = function(req, res, err)
res.end('Internal server error occured.');
* Log and forward to the default error page.
* @param {Object} req - Request object
* @param {Object} res - Response object
* @param {Object} err - Error object
* @param {String} [view] - Name of the error view to render
* @param {Object} [locals] - Locals to pass to the view
ErrorHelper.prototype.showErrorPage = function(req, res, err, view, locals)
locals.stack = (err.stack) ? err.stack : 'No stack trace present';
locals.err = (err.message) ? err.message : err;
res.render('error/' + (view || 'operation-failed'), locals);
* Log and write a flash message on the next request.
* @param {Object} req - Request object
* @param {Object} res - Response object
* @param {Object} err - Error object
* @param {Object} options - Options for the message
ErrorHelper.prototype.flash = function(req, res, err, options)
var message = options.message || ('An error occured. ' + options.entity +