BL-697: Improve handling of JavaScript errors

I don't suppose there's any easy way to get into the log the C# call stack as well?