This commit is contained in:
parent
7fd27cd7a5
commit
33da9c7fec
|
@ -1,10 +1,11 @@
|
|||
const SalixError = require('../../util/salixError');
|
||||
const UserError = require('../../util/user-error');
|
||||
const logToConsole = require('strong-error-handler/lib/logger');
|
||||
|
||||
module.exports = function() {
|
||||
return function(err, req, res, next) {
|
||||
// Thrown user errors
|
||||
if (err instanceof UserError) {
|
||||
if (err instanceof SalixError) {
|
||||
err.message = req.__(err.message, ...err.translateArgs);
|
||||
return next(err);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
module.exports = class ForbiddenError extends Error {
|
||||
const SalixError = require('./salixError');
|
||||
|
||||
module.exports = class ForbiddenError extends SalixError {
|
||||
constructor(message, code, ...translateArgs) {
|
||||
super(message);
|
||||
this.name = 'ForbiddenError';
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = class SalixError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
}
|
||||
};
|
|
@ -4,7 +4,9 @@
|
|||
* the final user, so they cannot contain sensitive data and must
|
||||
* be understandable by people who do not have a technical profile.
|
||||
*/
|
||||
module.exports = class UserError extends Error {
|
||||
const SalixError = require('./salixError');
|
||||
|
||||
module.exports = class UserError extends SalixError {
|
||||
constructor(message, code, ...translateArgs) {
|
||||
super(message);
|
||||
this.name = 'UserError';
|
||||
|
|
Loading…
Reference in New Issue