Emit an event object from atom.onDidThrowError

This commit is contained in:
Ben Ogle
2014-11-19 11:28:01 -08:00
parent e534997bf9
commit 74966bd547
2 changed files with 14 additions and 4 deletions

View File

@@ -114,5 +114,10 @@ describe "the `atom` global", ->
a + 1
catch e
error = e
window.onerror.call(window, e.toString(), 'abc', 2, e)
expect(didThrowSpy).toHaveBeenCalledWith(error.toString())
window.onerror.call(window, e.toString(), 'abc', 2, 3, e)
expect(didThrowSpy).toHaveBeenCalledWith
message: error.toString()
url: 'abc'
line: 2
column: 3
originalError: error

View File

@@ -187,7 +187,7 @@ class Atom extends Model
@executeJavaScriptInDevTools('InspectorFrontendAPI.showConsole()')
@emit 'uncaught-error', arguments...
@emitter.emit 'did-throw-error', message
@emitter.emit 'did-throw-error', {message, url, line, column, originalError}
@unsubscribe()
@setBodyPlatformClass()
@@ -277,7 +277,12 @@ class Atom extends Model
# Extended: Invoke the given callback whenever there is an unhandled error.
#
# * `callback` {Function} to be called whenever there is an unhandled error
# * `errorMessage` {String}
# * `event` {Object}
# * `originalError` {Object} the original error object
# * `message` {String} the original error object
# * `url` {String} Url to the file where the error originated.
# * `line` {Number}
# * `column` {Number}
#
# Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.
onDidThrowError: (callback) ->