Skip to content

Instantly share code, notes, and snippets.

@iwillig
Created January 9, 2015 03:51
Show Gist options
  • Save iwillig/c1dafb43cb8cf06e2dbf to your computer and use it in GitHub Desktop.
Save iwillig/c1dafb43cb8cf06e2dbf to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="/node_modules/source-map/dist/source-map.js"></script>
<script src="/web-worker-report.js"></script>
<script>
var worker = new Worker('test.js');
worker.onerror = function(e) {
reportError(e);
};
</script>
</head>
<body>
</body>
</html>
fetchSourceMap = (fileName) =>
response = null
xhr = new XMLHttpRequest()
xhr.onreadystatechange = () =>
if xhr.readyState == 4 and xhr.status == 200
response = xhr.responseText
xhr.onerror = (error) =>
throw error
xhr.open('GET', fileName + '.map', false)
xhr.send()
response
window.reportError = (error) =>
lineNumber = error.lineno
columnNumber = error.colno
rawSourceMap = fetchSourceMap error.filename
smc = new sourceMap.SourceMapConsumer rawSourceMap
console.log smc.originalPositionFor { line: error.lineno, column: error.colno }
# this
# is
# a bunch of
# space
# more code
fib = (n) =>
if n <= 2
1
fib(n - 1) + fib(n - 2)
throwError = -> throw new Error('hello world')
throwError()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment