zcatalyst-cli
Version:
Command Line Tool for CATALYST
31 lines (30 loc) • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (err, req, res, next) => {
switch (err.message) {
case 'INVALID_URL':
console.log('INVALID_URL : check if the url you are trying to access has an entry in api gateway');
res.status(404).json({
status: 'failure',
data: {
error_code: 'INVALID_URL',
message: `Invalid API ${req.url} with method ${req.method}`
}
});
break;
case 'NO_ACCESS':
console.log('NO_ACCESS : the url doesnt satisfy the authentication rule provided in api gateway');
res.status(401).json({
status: 'failure',
data: {
error_code: 'NO_ACCESS',
message: 'No privileges to perform this action.'
}
});
break;
default:
console.log('unidentified error : ', err);
next(err);
break;
}
};