mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
[Errors] migrate to OError
This commit is contained in:
parent
c7b9dadd16
commit
f82177a46a
4 changed files with 10 additions and 7 deletions
|
@ -1,8 +1,8 @@
|
|||
class CodedError extends Error {
|
||||
const OError = require('@overleaf/o-error')
|
||||
|
||||
class CodedError extends OError {
|
||||
constructor(message, code) {
|
||||
super(message)
|
||||
this.name = this.constructor.name
|
||||
this.code = code
|
||||
super(message, { code })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ module.exports = Router = {
|
|||
attrs.client_id = client.id
|
||||
attrs.err = error
|
||||
if (error.name === 'CodedError') {
|
||||
logger.warn(attrs, error.message, { code: error.code })
|
||||
const serializedError = { message: error.message, code: error.code }
|
||||
logger.warn(attrs, error.message)
|
||||
const serializedError = { message: error.message, code: error.info.code }
|
||||
callback(serializedError)
|
||||
} else if (error.message === 'unexpected arguments') {
|
||||
// the payload might be very large, put it on level info
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"format:fix": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --write"
|
||||
},
|
||||
"dependencies": {
|
||||
"@overleaf/o-error": "^3.0.0",
|
||||
"async": "^0.9.0",
|
||||
"base64id": "0.1.0",
|
||||
"basic-auth-connect": "^1.0.0",
|
||||
|
|
|
@ -152,7 +152,9 @@ describe('WebApiManager', function () {
|
|||
.calledWith(
|
||||
sinon.match({
|
||||
message: 'rate-limit hit when joining project',
|
||||
code: 'TooManyRequests'
|
||||
info: {
|
||||
code: 'TooManyRequests'
|
||||
}
|
||||
})
|
||||
)
|
||||
.should.equal(true)
|
||||
|
|
Loading…
Reference in a new issue