mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-22 21:33:44 +00:00
Merge pull request #20761 from overleaf/jpa-error-instance
[logger] forward an Error instance to Sentry.captureException GitOrigin-RevId: 3a310994622c85f3791181b87d4d382c34f6fd32
This commit is contained in:
parent
39ee8de1a5
commit
ea55a850f9
2 changed files with 10 additions and 2 deletions
|
@ -81,9 +81,13 @@ class SentryManager {
|
|||
extra.info = error.info
|
||||
delete error.info
|
||||
|
||||
// Sentry wants to receive an Error instance.
|
||||
const errInstance = new Error(error.message)
|
||||
Object.assign(errInstance, error)
|
||||
|
||||
try {
|
||||
// send the error to sentry
|
||||
this.Sentry.captureException(error, { tags, extra, level })
|
||||
this.Sentry.captureException(errInstance, { tags, extra, level })
|
||||
|
||||
// put a flag on the errors to avoid reporting them multiple times
|
||||
for (const key in attributes) {
|
||||
|
|
|
@ -138,7 +138,11 @@ describe('SentryManager', function () {
|
|||
},
|
||||
})
|
||||
)
|
||||
expect(this.Sentry.captureException.args[0][0]).to.deep.equal(expectedErr)
|
||||
// Chai is very picky with comparing Error instances. Go the long way of comparing all the fields manually.
|
||||
const gotErr = this.Sentry.captureException.args[0][0]
|
||||
for (const [key, wanted] of Object.entries(expectedErr)) {
|
||||
expect(gotErr).to.have.property(key, wanted)
|
||||
}
|
||||
})
|
||||
it('should sanitize request', function () {
|
||||
const req = {
|
||||
|
|
Loading…
Reference in a new issue