2020-02-03 10:24:25 +01:00
|
|
|
const statusCodes = require("./statusCodes")
|
2019-06-14 11:05:46 +02:00
|
|
|
|
|
|
|
const errorWithStatus = (message, statusCode) => {
|
2020-02-03 10:24:25 +01:00
|
|
|
const e = new Error(message)
|
|
|
|
e.statusCode = statusCode
|
|
|
|
return e
|
2019-06-14 11:05:46 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
module.exports.unauthorized = message =>
|
|
|
|
errorWithStatus(message, statusCodes.UNAUTHORIZED)
|
2019-06-14 11:05:46 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
module.exports.forbidden = message =>
|
|
|
|
errorWithStatus(message, statusCodes.FORBIDDEN)
|
2019-06-14 11:05:46 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
module.exports.notfound = message =>
|
|
|
|
errorWithStatus(message, statusCodes.NOT_FOUND)
|