Merge pull request #64 from tractorcow/pulls/stacktrace

API Support extended JS error reporting
This commit is contained in:
Ingo Schommer 2014-08-09 11:33:22 +12:00
commit 78cfd94240

View File

@ -76,8 +76,12 @@ class BasicContext extends BehatContext
public function appendErrorHandlerBeforeStep(StepEvent $event) public function appendErrorHandlerBeforeStep(StepEvent $event)
{ {
$javascript = <<<JS $javascript = <<<JS
window.onerror = function(msg) { window.onerror = function(message, file, line, column, error) {
var body = document.getElementsByTagName('body')[0]; var body = document.getElementsByTagName('body')[0];
var msg = message + " in " + file + ":" + line + ":" + column;
if(error !== undefined && error.stack !== undefined) {
msg += "\\nSTACKTRACE:\\n" + error.stack;
}
body.setAttribute('data-jserrors', '[captured JavaScript error] ' + msg); body.setAttribute('data-jserrors', '[captured JavaScript error] ' + msg);
} }
if ('undefined' !== typeof window.jQuery) { if ('undefined' !== typeof window.jQuery) {