2015-05-28 18:16:09 +03:00
|
|
|
// # Errors
|
2013-09-19 06:50:06 +04:00
|
|
|
/*jslint regexp: true */
|
2014-05-09 14:11:29 +04:00
|
|
|
var _ = require('lodash'),
|
2015-05-19 18:51:53 +03:00
|
|
|
chalk = require('chalk'),
|
2014-05-09 14:11:29 +04:00
|
|
|
path = require('path'),
|
2014-08-17 10:17:23 +04:00
|
|
|
Promise = require('bluebird'),
|
2014-05-09 14:11:29 +04:00
|
|
|
hbs = require('express-hbs'),
|
2014-09-19 20:17:58 +04:00
|
|
|
NotFoundError = require('./not-found-error'),
|
|
|
|
BadRequestError = require('./bad-request-error'),
|
|
|
|
InternalServerError = require('./internal-server-error'),
|
|
|
|
NoPermissionError = require('./no-permission-error'),
|
2014-09-23 12:23:10 +04:00
|
|
|
MethodNotAllowedError = require('./method-not-allowed-error'),
|
2014-09-19 20:17:58 +04:00
|
|
|
RequestEntityTooLargeError = require('./request-too-large-error'),
|
|
|
|
UnauthorizedError = require('./unauthorized-error'),
|
|
|
|
ValidationError = require('./validation-error'),
|
|
|
|
UnsupportedMediaTypeError = require('./unsupported-media-type-error'),
|
|
|
|
EmailError = require('./email-error'),
|
|
|
|
DataImportError = require('./data-import-error'),
|
2015-08-10 14:26:39 +03:00
|
|
|
TooManyRequestsError = require('./too-many-requests-error'),
|
2014-08-23 20:19:13 +04:00
|
|
|
config,
|
2013-09-17 14:56:05 +04:00
|
|
|
errors,
|
|
|
|
|
|
|
|
// Paths for views
|
2014-03-05 07:22:00 +04:00
|
|
|
userErrorTemplateExists = false;
|
2013-06-25 15:43:15 +04:00
|
|
|
|
2014-08-23 20:19:13 +04:00
|
|
|
// Shim right now to deal with circular dependencies.
|
2014-09-22 00:54:32 +04:00
|
|
|
// @TODO(hswolff): remove circular dependency and lazy require.
|
2014-08-23 20:19:13 +04:00
|
|
|
function getConfigModule() {
|
|
|
|
if (!config) {
|
|
|
|
config = require('../config');
|
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
/**
|
|
|
|
* Basic error handling helpers
|
|
|
|
*/
|
|
|
|
errors = {
|
2014-03-27 00:43:16 +04:00
|
|
|
updateActiveTheme: function (activeTheme) {
|
2014-08-23 20:19:13 +04:00
|
|
|
userErrorTemplateExists = getConfigModule().paths.availableThemes[activeTheme].hasOwnProperty('error.hbs');
|
2013-10-21 20:59:37 +04:00
|
|
|
},
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
throwError: function (err) {
|
|
|
|
if (!err) {
|
2014-07-25 02:07:29 +04:00
|
|
|
err = new Error('An error occurred');
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
if (_.isString(err)) {
|
|
|
|
throw new Error(err);
|
|
|
|
}
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
throw err;
|
|
|
|
},
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2014-01-03 19:50:03 +04:00
|
|
|
// ## Reject Error
|
|
|
|
// Used to pass through promise errors when we want to handle them at a later time
|
|
|
|
rejectError: function (err) {
|
2014-08-17 10:17:23 +04:00
|
|
|
return Promise.reject(err);
|
2014-01-03 19:50:03 +04:00
|
|
|
},
|
|
|
|
|
2014-07-10 19:10:00 +04:00
|
|
|
logInfo: function (component, info) {
|
|
|
|
if ((process.env.NODE_ENV === 'development' ||
|
|
|
|
process.env.NODE_ENV === 'staging' ||
|
|
|
|
process.env.NODE_ENV === 'production')) {
|
2015-05-19 18:51:53 +03:00
|
|
|
console.info(chalk.cyan(component + ':', info));
|
2014-07-10 19:10:00 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-10-18 01:49:14 +04:00
|
|
|
logWarn: function (warn, context, help) {
|
|
|
|
if ((process.env.NODE_ENV === 'development' ||
|
|
|
|
process.env.NODE_ENV === 'staging' ||
|
|
|
|
process.env.NODE_ENV === 'production')) {
|
2014-09-21 01:11:30 +04:00
|
|
|
warn = warn || 'no message supplied';
|
2015-05-19 18:51:53 +03:00
|
|
|
var msgs = [chalk.yellow('\nWarning:', warn), '\n'];
|
2013-10-18 01:49:14 +04:00
|
|
|
|
|
|
|
if (context) {
|
2015-05-19 18:51:53 +03:00
|
|
|
msgs.push(chalk.white(context), '\n');
|
2013-10-18 01:49:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (help) {
|
2015-05-19 18:51:53 +03:00
|
|
|
msgs.push(chalk.green(help));
|
2013-10-18 01:49:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// add a new line
|
2014-03-22 02:31:58 +04:00
|
|
|
msgs.push('\n');
|
|
|
|
|
|
|
|
console.log.apply(console, msgs);
|
2013-10-18 01:49:14 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-09-15 15:11:47 +04:00
|
|
|
logError: function (err, context, help) {
|
2014-08-07 21:50:23 +04:00
|
|
|
var self = this,
|
|
|
|
origArgs = _.toArray(arguments).slice(1),
|
|
|
|
stack,
|
|
|
|
msgs;
|
|
|
|
|
2014-07-15 15:03:12 +04:00
|
|
|
if (_.isArray(err)) {
|
|
|
|
_.each(err, function (e) {
|
2014-08-07 21:50:23 +04:00
|
|
|
var newArgs = [e].concat(origArgs);
|
|
|
|
errors.logError.apply(self, newArgs);
|
2014-07-15 15:03:12 +04:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-07 21:50:23 +04:00
|
|
|
stack = err ? err.stack : null;
|
2014-03-22 02:31:58 +04:00
|
|
|
|
2014-11-05 06:03:33 +03:00
|
|
|
if (!_.isString(err)) {
|
|
|
|
if (_.isObject(err) && _.isString(err.message)) {
|
|
|
|
err = err.message;
|
|
|
|
} else {
|
|
|
|
err = 'An unknown error occurred.';
|
|
|
|
}
|
|
|
|
}
|
2014-09-10 08:06:24 +04:00
|
|
|
|
2014-08-08 13:16:51 +04:00
|
|
|
// Overwrite error to provide information that this is probably a permission problem
|
|
|
|
// TODO: https://github.com/TryGhost/Ghost/issues/3687
|
|
|
|
if (err.indexOf('SQLITE_READONLY') !== -1) {
|
2014-09-10 08:06:24 +04:00
|
|
|
context = 'Your database is in read only mode. Visitors can read your blog, but you can\'t log in or add posts.';
|
|
|
|
help = 'Check your database file and make sure that file owner and permissions are correct.';
|
2014-08-08 13:16:51 +04:00
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
// TODO: Logging framework hookup
|
2013-09-17 14:56:05 +04:00
|
|
|
// Eventually we'll have better logging which will know about envs
|
2013-09-19 06:50:06 +04:00
|
|
|
if ((process.env.NODE_ENV === 'development' ||
|
|
|
|
process.env.NODE_ENV === 'staging' ||
|
|
|
|
process.env.NODE_ENV === 'production')) {
|
2015-05-19 18:51:53 +03:00
|
|
|
msgs = [chalk.red('\nERROR:', err), '\n'];
|
2013-09-15 15:11:47 +04:00
|
|
|
|
|
|
|
if (context) {
|
2015-05-19 18:51:53 +03:00
|
|
|
msgs.push(chalk.white(context), '\n');
|
2013-09-15 15:11:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (help) {
|
2015-05-19 18:51:53 +03:00
|
|
|
msgs.push(chalk.green(help));
|
2013-09-15 15:11:47 +04:00
|
|
|
}
|
2013-09-19 06:50:06 +04:00
|
|
|
|
2013-09-15 15:11:47 +04:00
|
|
|
// add a new line
|
2014-03-22 02:31:58 +04:00
|
|
|
msgs.push('\n');
|
2013-09-19 06:50:06 +04:00
|
|
|
|
|
|
|
if (stack) {
|
2014-03-22 02:31:58 +04:00
|
|
|
msgs.push(stack, '\n');
|
2013-09-19 06:50:06 +04:00
|
|
|
}
|
2014-03-22 02:31:58 +04:00
|
|
|
|
|
|
|
console.error.apply(console, msgs);
|
2013-07-16 22:57:19 +04:00
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
},
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2013-09-15 15:11:47 +04:00
|
|
|
logErrorAndExit: function (err, context, help) {
|
|
|
|
this.logError(err, context, help);
|
|
|
|
// Exit with 0 to prevent npm errors as we have our own
|
|
|
|
process.exit(0);
|
2013-06-25 15:43:15 +04:00
|
|
|
},
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2013-09-15 15:11:47 +04:00
|
|
|
logAndThrowError: function (err, context, help) {
|
|
|
|
this.logError(err, context, help);
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2013-09-15 15:11:47 +04:00
|
|
|
this.throwError(err, context, help);
|
2013-06-25 15:43:15 +04:00
|
|
|
},
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2014-07-15 15:03:12 +04:00
|
|
|
logAndRejectError: function (err, context, help) {
|
|
|
|
this.logError(err, context, help);
|
|
|
|
|
2014-07-25 02:07:29 +04:00
|
|
|
return this.rejectError(err, context, help);
|
2014-07-15 15:03:12 +04:00
|
|
|
},
|
|
|
|
|
2013-09-15 15:11:47 +04:00
|
|
|
logErrorWithRedirect: function (msg, context, help, redirectTo, req, res) {
|
2014-02-27 06:44:09 +04:00
|
|
|
/*jshint unused:false*/
|
2013-06-25 15:43:15 +04:00
|
|
|
var self = this;
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
return function () {
|
2013-09-15 15:11:47 +04:00
|
|
|
self.logError(msg, context, help);
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
if (_.isFunction(res.redirect)) {
|
|
|
|
res.redirect(redirectTo);
|
|
|
|
}
|
|
|
|
};
|
2013-09-17 14:56:05 +04:00
|
|
|
},
|
|
|
|
|
2015-06-14 22:07:52 +03:00
|
|
|
/**
|
|
|
|
* ### Format HTTP Errors
|
|
|
|
* Converts the error response from the API into a format which can be returned over HTTP
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {Array} error
|
|
|
|
* @return {{errors: Array, statusCode: number}}
|
|
|
|
*/
|
|
|
|
formatHttpErrors: function formatHttpErrors(error) {
|
|
|
|
var statusCode = 500,
|
|
|
|
errors = [];
|
|
|
|
|
|
|
|
if (!_.isArray(error)) {
|
|
|
|
error = [].concat(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
_.each(error, function each(errorItem) {
|
|
|
|
var errorContent = {};
|
|
|
|
|
|
|
|
// TODO: add logic to set the correct status code
|
|
|
|
statusCode = errorItem.code || 500;
|
|
|
|
|
|
|
|
errorContent.message = _.isString(errorItem) ? errorItem :
|
|
|
|
(_.isObject(errorItem) ? errorItem.message : 'Unknown API Error');
|
|
|
|
errorContent.errorType = errorItem.errorType || 'InternalServerError';
|
|
|
|
errors.push(errorContent);
|
|
|
|
});
|
|
|
|
|
|
|
|
return {errors: errors, statusCode: statusCode};
|
|
|
|
},
|
|
|
|
|
2015-10-22 16:28:47 +03:00
|
|
|
formatAndRejectAPIError: function (error, permsMessage) {
|
2014-07-25 02:07:29 +04:00
|
|
|
if (!error) {
|
2014-07-31 04:15:34 +04:00
|
|
|
return this.rejectError(
|
|
|
|
new this.NoPermissionError(permsMessage || 'You do not have permission to perform this action')
|
|
|
|
);
|
2014-07-25 02:07:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_.isString(error)) {
|
|
|
|
return this.rejectError(new this.NoPermissionError(error));
|
|
|
|
}
|
|
|
|
|
2015-04-22 23:29:45 +03:00
|
|
|
if (error.errorType) {
|
2014-07-25 02:07:29 +04:00
|
|
|
return this.rejectError(error);
|
|
|
|
}
|
|
|
|
|
2015-01-21 21:01:19 +03:00
|
|
|
// handle database errors
|
|
|
|
if (error.code && (error.errno || error.detail)) {
|
|
|
|
error.db_error_code = error.code;
|
2015-04-22 23:29:45 +03:00
|
|
|
error.errorType = 'DatabaseError';
|
2015-01-21 21:01:19 +03:00
|
|
|
error.code = 500;
|
|
|
|
|
|
|
|
return this.rejectError(error);
|
|
|
|
}
|
|
|
|
|
2014-07-25 02:07:29 +04:00
|
|
|
return this.rejectError(new this.InternalServerError(error));
|
|
|
|
},
|
|
|
|
|
2015-10-22 16:28:47 +03:00
|
|
|
handleAPIError: function errorHandler(err, req, res, next) {
|
|
|
|
/*jshint unused:false */
|
|
|
|
var httpErrors = this.formatHttpErrors(err);
|
|
|
|
this.logError(err);
|
|
|
|
// Send a properly formatted HTTP response containing the errors
|
|
|
|
res.status(httpErrors.statusCode).json({errors: httpErrors.errors});
|
|
|
|
},
|
|
|
|
|
2013-09-17 14:56:05 +04:00
|
|
|
renderErrorPage: function (code, err, req, res, next) {
|
2014-02-27 06:44:09 +04:00
|
|
|
/*jshint unused:false*/
|
2014-08-23 20:19:13 +04:00
|
|
|
var self = this,
|
|
|
|
defaultErrorTemplatePath = path.resolve(getConfigModule().paths.adminViews, 'user-error.hbs');
|
2014-01-23 21:52:18 +04:00
|
|
|
|
2013-09-19 06:50:06 +04:00
|
|
|
function parseStack(stack) {
|
2013-10-25 23:31:53 +04:00
|
|
|
if (!_.isString(stack)) {
|
2013-09-19 06:50:06 +04:00
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: split out line numbers
|
|
|
|
var stackRegex = /\s*at\s*(\w+)?\s*\(([^\)]+)\)\s*/i;
|
|
|
|
|
|
|
|
return (
|
|
|
|
stack
|
|
|
|
.split(/[\r\n]+/)
|
|
|
|
.slice(1)
|
|
|
|
.map(function (line) {
|
|
|
|
var parts = line.match(stackRegex);
|
|
|
|
if (!parts) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2014-09-10 08:06:24 +04:00
|
|
|
function: parts[1],
|
|
|
|
at: parts[2]
|
2013-09-19 06:50:06 +04:00
|
|
|
};
|
|
|
|
})
|
|
|
|
.filter(function (line) {
|
|
|
|
return !!line;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-09-17 14:56:05 +04:00
|
|
|
// Render the error!
|
2013-09-18 09:12:53 +04:00
|
|
|
function renderErrorInt(errorView) {
|
2013-09-19 06:50:06 +04:00
|
|
|
var stack = null;
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
if (process.env.NODE_ENV !== 'production' && err.stack) {
|
2013-09-19 06:50:06 +04:00
|
|
|
stack = parseStack(err.stack);
|
|
|
|
}
|
|
|
|
|
2013-10-17 23:42:15 +04:00
|
|
|
res.status(code).render((errorView || 'error'), {
|
2013-09-17 14:56:05 +04:00
|
|
|
message: err.message || err,
|
2013-09-19 06:50:06 +04:00
|
|
|
code: code,
|
|
|
|
stack: stack
|
2014-01-23 21:52:18 +04:00
|
|
|
}, function (templateErr, html) {
|
|
|
|
if (!templateErr) {
|
2014-08-09 17:48:58 +04:00
|
|
|
return res.status(code).send(html);
|
2014-01-23 21:52:18 +04:00
|
|
|
}
|
|
|
|
// There was an error trying to render the error page, output the error
|
|
|
|
self.logError(templateErr, 'Error whilst rendering error page', 'Error template has an error');
|
|
|
|
|
|
|
|
// And then try to explain things to the user...
|
|
|
|
// Cheat and output the error using handlebars escapeExpression
|
2014-08-09 17:48:58 +04:00
|
|
|
return res.status(500).send(
|
2015-02-06 23:30:35 +03:00
|
|
|
'<h1>Oops, seems there is an error in the error template.</h1>' +
|
2014-07-25 02:07:29 +04:00
|
|
|
'<p>Encountered the error: </p>' +
|
|
|
|
'<pre>' + hbs.handlebars.Utils.escapeExpression(templateErr.message || templateErr) + '</pre>' +
|
|
|
|
'<br ><p>whilst trying to render an error page for the error: </p>' +
|
|
|
|
code + ' ' + '<pre>' + hbs.handlebars.Utils.escapeExpression(err.message || err) + '</pre>'
|
|
|
|
);
|
2013-09-17 14:56:05 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (code >= 500) {
|
2014-07-25 02:07:29 +04:00
|
|
|
this.logError(err, 'Rendering Error Page', 'Ghost caught a processing error in the middleware layer.');
|
2013-09-17 14:56:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Are we admin? If so, don't worry about the user template
|
2014-06-30 16:58:10 +04:00
|
|
|
if ((res.isAdmin && req.user && req.user.id) || userErrorTemplateExists === true) {
|
2013-09-17 14:56:05 +04:00
|
|
|
return renderErrorInt();
|
|
|
|
}
|
|
|
|
|
2013-09-18 09:12:53 +04:00
|
|
|
// We're not admin and the template doesn't exist. Render the default.
|
2014-01-03 00:57:37 +04:00
|
|
|
return renderErrorInt(defaultErrorTemplatePath);
|
2013-09-17 14:56:05 +04:00
|
|
|
},
|
|
|
|
|
2013-10-18 01:49:14 +04:00
|
|
|
error404: function (req, res, next) {
|
2015-06-08 13:13:42 +03:00
|
|
|
var message = 'Page not found';
|
2013-10-18 01:49:14 +04:00
|
|
|
|
2014-03-05 07:22:00 +04:00
|
|
|
// do not cache 404 error
|
|
|
|
res.set({'Cache-Control': 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'});
|
2013-10-18 01:49:14 +04:00
|
|
|
if (req.method === 'GET') {
|
|
|
|
this.renderErrorPage(404, message, req, res, next);
|
|
|
|
} else {
|
2014-08-09 17:48:58 +04:00
|
|
|
res.status(404).send(message);
|
2013-10-18 01:49:14 +04:00
|
|
|
}
|
2013-09-19 06:50:06 +04:00
|
|
|
},
|
|
|
|
|
2013-10-18 01:49:14 +04:00
|
|
|
error500: function (err, req, res, next) {
|
2013-12-31 03:13:25 +04:00
|
|
|
// 500 errors should never be cached
|
|
|
|
res.set({'Cache-Control': 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'});
|
|
|
|
|
|
|
|
if (err.status === 404) {
|
|
|
|
return this.error404(req, res, next);
|
|
|
|
}
|
|
|
|
|
2013-10-18 01:49:14 +04:00
|
|
|
if (req.method === 'GET') {
|
|
|
|
if (!err || !(err instanceof Error)) {
|
|
|
|
next();
|
|
|
|
}
|
2015-09-22 19:38:30 +03:00
|
|
|
errors.renderErrorPage(err.status || err.code || 500, err, req, res, next);
|
2013-10-18 01:49:14 +04:00
|
|
|
} else {
|
2014-07-17 16:22:07 +04:00
|
|
|
var statusCode = 500,
|
2014-08-08 11:44:24 +04:00
|
|
|
returnErrors = [];
|
2014-07-17 16:22:07 +04:00
|
|
|
|
2014-08-08 11:44:24 +04:00
|
|
|
if (!_.isArray(err)) {
|
|
|
|
err = [].concat(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
_.each(err, function (errorItem) {
|
|
|
|
var errorContent = {};
|
|
|
|
|
|
|
|
statusCode = errorItem.code || 500;
|
|
|
|
|
|
|
|
errorContent.message = _.isString(errorItem) ? errorItem :
|
|
|
|
(_.isObject(errorItem) ? errorItem.message : 'Unknown Error');
|
2015-04-22 23:29:45 +03:00
|
|
|
errorContent.errorType = errorItem.errorType || 'InternalServerError';
|
2014-08-08 11:44:24 +04:00
|
|
|
returnErrors.push(errorContent);
|
|
|
|
});
|
2014-07-17 16:22:07 +04:00
|
|
|
|
2014-08-09 17:48:58 +04:00
|
|
|
res.status(statusCode).json({errors: returnErrors});
|
2013-09-19 06:50:06 +04:00
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
};
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2014-02-05 12:40:30 +04:00
|
|
|
// Ensure our 'this' context for methods and preserve method arity by
|
|
|
|
// using Function#bind for expressjs
|
|
|
|
_.each([
|
2014-07-25 02:07:29 +04:00
|
|
|
'logWarn',
|
|
|
|
'logInfo',
|
|
|
|
'rejectError',
|
|
|
|
'throwError',
|
|
|
|
'logError',
|
2013-09-24 14:46:30 +04:00
|
|
|
'logAndThrowError',
|
2014-07-25 02:07:29 +04:00
|
|
|
'logAndRejectError',
|
|
|
|
'logErrorAndExit',
|
2013-09-24 14:46:30 +04:00
|
|
|
'logErrorWithRedirect',
|
2014-07-25 02:07:29 +04:00
|
|
|
'handleAPIError',
|
2015-10-22 16:28:47 +03:00
|
|
|
'formatAndRejectAPIError',
|
2015-06-14 22:07:52 +03:00
|
|
|
'formatHttpErrors',
|
2013-09-24 14:46:30 +04:00
|
|
|
'renderErrorPage',
|
2013-10-18 01:49:14 +04:00
|
|
|
'error404',
|
|
|
|
'error500'
|
2014-02-05 12:40:30 +04:00
|
|
|
], function (funcName) {
|
|
|
|
errors[funcName] = errors[funcName].bind(errors);
|
|
|
|
});
|
2013-05-26 22:51:58 +04:00
|
|
|
|
2014-05-09 14:11:29 +04:00
|
|
|
module.exports = errors;
|
|
|
|
module.exports.NotFoundError = NotFoundError;
|
|
|
|
module.exports.BadRequestError = BadRequestError;
|
|
|
|
module.exports.InternalServerError = InternalServerError;
|
|
|
|
module.exports.NoPermissionError = NoPermissionError;
|
|
|
|
module.exports.UnauthorizedError = UnauthorizedError;
|
|
|
|
module.exports.ValidationError = ValidationError;
|
|
|
|
module.exports.RequestEntityTooLargeError = RequestEntityTooLargeError;
|
2014-05-24 10:05:12 +04:00
|
|
|
module.exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
|
2014-05-09 03:12:18 +04:00
|
|
|
module.exports.EmailError = EmailError;
|
2014-07-29 01:41:45 +04:00
|
|
|
module.exports.DataImportError = DataImportError;
|
2014-09-23 12:23:10 +04:00
|
|
|
module.exports.MethodNotAllowedError = MethodNotAllowedError;
|
2015-08-10 14:26:39 +03:00
|
|
|
module.exports.TooManyRequestsError = TooManyRequestsError;
|