mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-06 07:39:02 +02:00
Merge pull request #7 from sharelatex/bg-filter-path-in-errors
remove the path in the message from fs errors
This commit is contained in:
@@ -50,6 +50,10 @@ module.exports = Logger =
|
||||
for own key, value of error
|
||||
newError[key] = value
|
||||
error = newError
|
||||
# filter paths from the message to avoid duplicate errors in sentry
|
||||
# (e.g. errors from `fs` methods which have a path attribute)
|
||||
try
|
||||
error.message = error.message.replace(" '#{error.path}'", '') if error.path
|
||||
# send the error to sentry
|
||||
try
|
||||
@raven.captureException(error, {tags: tags, extra: extra, level: level})
|
||||
|
||||
@@ -40,6 +40,12 @@ describe 'logger.error', ->
|
||||
@logger.error {bar: error2}, "second message"
|
||||
@captureException.callCount.should.equal 2
|
||||
|
||||
it 'should remove the path from fs errors', () ->
|
||||
fsError = new Error("Error: ENOENT: no such file or directory, stat '/tmp/3279b8d0-da10-11e8-8255-efd98985942b'")
|
||||
fsError.path = "/tmp/3279b8d0-da10-11e8-8255-efd98985942b"
|
||||
@logger.error {err: fsError}, "message"
|
||||
@captureException.calledWith(sinon.match.has('message', 'Error: ENOENT: no such file or directory, stat')).should.equal true
|
||||
|
||||
it 'for multiple errors should only report a maximum of 5 errors to sentry', () ->
|
||||
@logger.error {foo:'bar'}, "message"
|
||||
@logger.error {foo:'bar'}, "message"
|
||||
|
||||
Reference in New Issue
Block a user