I am trying to get useful errors out of dart2js generated javascript.
By placing this code in my index.html:
window.addEventListener(
'error',
function(e){
ga(
'send',
'event',
'JS Error',
'msg:'+e.message,
'line:'+e.lineno+' col:'+ e.colno+' file:'+e.filename,
{'nonInteraction':1}
);
},false);
I get google analytics to give me line-numbers and column-numbers of errors that occur for users of my website.
Then I am using Mozilla's source-map consumer to find out where the original error occurred, like this (using github/mozilla/source-map/):
// some code removed for readability
require(["source-map/source-map-consumer"], function(SMC) {
var input = {
line: parseInt(line),
column: parseInt(col)
};
// rawSourceMap contains the dart2js generated source-map
var smc = new SMC.SourceMapConsumer(rawSourceMap);
console.log(smc.originalPositionFor(input));
The problem is that all I ever get is:
{
"source": null,
"line": null,
"column": null,
"name": null
}
While I am expecting something like
{
"source": "image.dart",
"line": 324,
"column": 2,
"name": "clickController"
}
What I found out so far is that the line numbers of errors are something like this line: 6862, column: 31
(a high line number a and a low column number).
After some testing and using smc.eachMapping()
, I found out that linenumbers that give a result are like line: 7140, column: 1692
(high line number and high column number).
My question:
Does anybody have an idea why the dart2js javascript file generates errors that the dart2js source-map file cannot understand? (and how to fix this)
Kind regards and thanks for any help,
Hendrik Jan
Some extra info:
The pubspec.yaml looks like this:
name: bones
description: A sample web application
dependencies:
browser: any
observe: any
transformers:
- $dart2js: {"minify":true, "checked":false}
I've already tried "minify":false
and "checked":true
to no avail.
An error looks like this:
Uncaught Uncaught Error: Invalid argument(s) Stack Trace: Invalid argument(s) at dart.b (.../script.dart.js?0:1245:3) at F.dart.F.T (.../script.dart.js?0:479:48) at J.aF ... and so on ...