mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3 from overleaf/ta-info-undefined
Handle Custom Errors Created Without Info
This commit is contained in:
commit
c63cc52fda
2 changed files with 14 additions and 1 deletions
|
@ -30,8 +30,10 @@ class ErrorTypeError extends Error {
|
||||||
constructor ({ message, info }) {
|
constructor ({ message, info }) {
|
||||||
super(message)
|
super(message)
|
||||||
this.name = this.constructor.name
|
this.name = this.constructor.name
|
||||||
|
if (info) {
|
||||||
this.info = info
|
this.info = info
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap the given error, which caused this error.
|
* Wrap the given error, which caused this error.
|
||||||
|
|
|
@ -95,6 +95,17 @@ describe('errorType.Error', () => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('handles a custom error without info', () => {
|
||||||
|
try {
|
||||||
|
throw new CustomError1({})
|
||||||
|
expect.fail('should have thrown')
|
||||||
|
} catch (e) {
|
||||||
|
expect(errorType.getFullInfo(e)).to.deep.equal({})
|
||||||
|
let infoKey = Object.keys(e).find(k => k === 'info')
|
||||||
|
expect(infoKey).to.not.exist
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('errorType.ErrorWithStatusCode', () => {
|
describe('errorType.ErrorWithStatusCode', () => {
|
||||||
|
|
Loading…
Reference in a new issue