mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add error handling for InvalidError
This commit is contained in:
parent
e99165b475
commit
bf60fe7f6c
2 changed files with 12 additions and 0 deletions
|
@ -25,6 +25,10 @@ module.exports = ErrorController =
|
|||
else if error instanceof Errors.TooManyRequestsError
|
||||
logger.warn {err: error, url: req.url}, "too many requests error"
|
||||
res.sendStatus(429)
|
||||
else if error instanceof Errors.InvalidError
|
||||
logger.warn {err: error, url: req.url}, "invalid error"
|
||||
res.status(400)
|
||||
res.send(error.message)
|
||||
else if error instanceof Errors.InvalidNameError
|
||||
logger.warn {err: error, url: req.url}, "invalid name error"
|
||||
res.status(400)
|
||||
|
|
|
@ -82,6 +82,13 @@ EmailExistsError = (message) ->
|
|||
return error
|
||||
EmailExistsError.prototype.__proto__ = Error.prototype
|
||||
|
||||
InvalidError = (message) ->
|
||||
error = new Error(message)
|
||||
error.name = "InvalidError"
|
||||
error.__proto__ = InvalidError.prototype
|
||||
return error
|
||||
InvalidError.prototype.__proto__ = Error.prototype
|
||||
|
||||
module.exports = Errors =
|
||||
NotFoundError: NotFoundError
|
||||
ServiceNotConfiguredError: ServiceNotConfiguredError
|
||||
|
@ -95,3 +102,4 @@ module.exports = Errors =
|
|||
V1ConnectionError: V1ConnectionError
|
||||
UnconfirmedEmailError: UnconfirmedEmailError
|
||||
EmailExistsError: EmailExistsError
|
||||
InvalidError: InvalidError
|
||||
|
|
Loading…
Reference in a new issue