1
0
Fork 0
mirror of synced 2024-07-04 05:50:57 +12:00
budibase/packages/server/utilities/exceptions.js

16 lines
468 B
JavaScript
Raw Normal View History

2019-06-14 21:05:46 +12:00
const statusCodes = require("./statusCodes");
const errorWithStatus = (message, statusCode) => {
const e = new Error(message);
e.statusCode = statusCode;
return e;
}
module.exports.unauthorized = (message) =>
errorWithStatus(message, statusCodes.UNAUTHORIZED);
module.exports.forbidden = (message) =>
errorWithStatus(message, statusCodes.FORBIDDEN);
module.exports.notfound = (message) =>
errorWithStatus(message, statusCodes.NOT_FOUND);