mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 21:52:07 +00:00
ee85d948e2
GitOrigin-RevId: ef2ef77e26df59d1af3df6dc664e284d3c70102d
17 lines
541 B
JavaScript
17 lines
541 B
JavaScript
'use strict'
|
|
|
|
const HTTPStatus = require('http-status')
|
|
|
|
function makeErrorRenderer(status) {
|
|
return (res, message) => {
|
|
res.status(status).json({ message: message || HTTPStatus[status] })
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
badRequest: makeErrorRenderer(HTTPStatus.BAD_REQUEST),
|
|
notFound: makeErrorRenderer(HTTPStatus.NOT_FOUND),
|
|
unprocessableEntity: makeErrorRenderer(HTTPStatus.UNPROCESSABLE_ENTITY),
|
|
conflict: makeErrorRenderer(HTTPStatus.CONFLICT),
|
|
requestEntityTooLarge: makeErrorRenderer(HTTPStatus.REQUEST_ENTITY_TOO_LARGE),
|
|
}
|