mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Don't throw error if the function is not invoked with callback.
Instead, log the error and return early.
This commit is contained in:
parent
9846703be5
commit
31235beee5
2 changed files with 5 additions and 7 deletions
|
@ -93,12 +93,10 @@ describe 'timeAsyncMethod', ->
|
|||
@testObject.nextNumber = (n) ->
|
||||
return n+1
|
||||
|
||||
it 'should throw an error', ->
|
||||
it 'should not throw an error', ->
|
||||
@timeAsyncMethod @testObject, 'nextNumber', 'test.nextNumber'
|
||||
badCall = () =>
|
||||
@testObject.nextNumber 2
|
||||
expect(badCall).to.throw(
|
||||
/^.*expected wrapped method 'nextNumber' to be invoked with a callback.*$/
|
||||
)
|
||||
expect(badCall).to.not.throw(Error)
|
||||
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ module.exports = (obj, methodName, prefix, logger) ->
|
|||
obj[methodName] = (originalArgs...) ->
|
||||
|
||||
[firstArgs..., callback] = originalArgs
|
||||
|
||||
if !callback? || typeof callback != 'function'
|
||||
throw new Error(
|
||||
"[Metrics] expected wrapped method '#{methodName}' to be invoked with a callback"
|
||||
)
|
||||
logger.log "[Metrics] expected wrapped method '#{methodName}' to be invoked with a callback"
|
||||
return
|
||||
|
||||
timer = new metrics.Timer(key)
|
||||
|
||||
|
|
Loading…
Reference in a new issue