Allow metadata to be passed to atom.assert

This commit is contained in:
Nathan Sobo
2017-02-13 10:29:04 -07:00
committed by Antonio Scandurra
parent 01f0bd56af
commit 2ad6f83239
2 changed files with 12 additions and 2 deletions

View File

@@ -821,12 +821,17 @@ class AtomEnvironment extends Model
Section: Private
###
assert: (condition, message, callback) ->
assert: (condition, message, callbackOrMetadata) ->
return true if condition
error = new Error("Assertion failed: #{message}")
Error.captureStackTrace(error, @assert)
callback?(error)
if callbackOrMetadata?
if typeof callbackOrMetadata is 'function'
callbackOrMetadata?(error)
else
error.metadata = callbackOrMetadata
@emitter.emit 'did-fail-assertion', error