Map line numbers in onerror handler w/ source-map-support

This commit is contained in:
Max Brunsfeld 2015-08-20 10:00:38 -07:00
parent 2285e8a42c
commit 1bfbf7f9d3
3 changed files with 3 additions and 10 deletions

View File

@ -22,7 +22,6 @@
"clear-cut": "^2.0.1",
"coffee-cash": "0.8.0",
"coffee-script": "1.8.0",
"coffeestack": "^1.1.2",
"color": "^0.7.3",
"delegato": "^1",
"emissary": "^1.3.3",

View File

@ -1,11 +1,9 @@
path = require 'path'
_ = require 'underscore-plus'
{convertStackTrace} = require 'coffeestack'
{View, $, $$} = require '../src/space-pen-extensions'
grim = require 'grim'
marked = require 'marked'
sourceMaps = {}
formatStackTrace = (spec, message='', stackTrace) ->
return stackTrace unless stackTrace
@ -15,8 +13,8 @@ formatStackTrace = (spec, message='', stackTrace) ->
for line in stackTrace.split('\n')
convertedLines.push(line) unless jasminePattern.test(line)
break if firstJasmineLinePattern.test(line)
stackTrace = convertedLines.join('\n')
stackTrace = convertStackTrace(convertedLines.join('\n'), sourceMaps)
lines = stackTrace.split('\n')
# Remove first line of stack when it is the same as the error message

View File

@ -9,7 +9,7 @@ _ = require 'underscore-plus'
{deprecate, includeDeprecatedAPIs} = require 'grim'
{CompositeDisposable, Emitter} = require 'event-kit'
fs = require 'fs-plus'
{convertStackTrace, convertLine} = require 'coffeestack'
{mapSourcePosition} = require 'source-map-support'
Model = require './model'
{$} = require './space-pen-extensions'
WindowEventHandler = require './window-event-handler'
@ -196,15 +196,11 @@ class Atom extends Model
#
# Call after this instance has been assigned to the `atom` global.
initialize: ->
sourceMapCache = {}
window.onerror = =>
@lastUncaughtError = Array::slice.call(arguments)
[message, url, line, column, originalError] = @lastUncaughtError
convertedLine = convertLine(url, line, column, sourceMapCache)
{line, column} = convertedLine if convertedLine?
originalError.stack = convertStackTrace(originalError.stack, sourceMapCache) if originalError
{line, column} = mapSourcePosition({source: url, line, column})
eventObject = {message, url, line, column, originalError}