private void OnJavascriptError(object sender, JavascriptErrorEventArgs e)
{
if(e.Message.Contains("sourceMapping"))
return;
var file = e.Filename.Split(new char[] { '/' }).Last();
var line = (int) e.Line;
var dir = FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot);
var mapPath = Path.Combine(dir, file + ".map");
if(RobustFile.Exists(mapPath))
{
var consumer = new SourceMapDotNet.SourceMapConsumer(RobustFile.ReadAllText(mapPath));
foreach(var match in consumer.OriginalPositionsFor(line))
{
file = match.File;
line = match.LineNumber;
break;
}
}
Debug.WriteLine("{0} in {1}:{2}", e.Message,file, line);
NonFatalProblem.Report(ModalIf.None, PassiveIf.All, e.Message,
string.Format("{0} in {1}:{2}", e.Message, file, line));
}