mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Allow metadata to be passed to atom.assert
This commit is contained in:
committed by
Antonio Scandurra
parent
01f0bd56af
commit
2ad6f83239
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user