Use the documented interface to pick the error instance from the global error handler
This commit is contained in:
@@ -3,16 +3,14 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
|
|||||||
var handlers = [];
|
var handlers = [];
|
||||||
global = global || j$.getGlobal();
|
global = global || j$.getGlobal();
|
||||||
|
|
||||||
var onerror = function onerror() {
|
var onerror = function onerror(message, source, lineno, colno, error) {
|
||||||
var handler = handlers[handlers.length - 1];
|
var handler = handlers[handlers.length - 1];
|
||||||
|
|
||||||
if (handler) {
|
if (handler) {
|
||||||
// Get error from (message, source, lineno, colno, error)
|
|
||||||
var args = Array.prototype.slice.call(arguments, 0);
|
var args = Array.prototype.slice.call(arguments, 0);
|
||||||
var error = args.find(function(arg) {
|
// Prefer passing the error to the error handler
|
||||||
return arg instanceof Error;
|
// to be able to print the stack trace.
|
||||||
});
|
handler.apply(null, error instanceof Error ? [error] : args);
|
||||||
handler.apply(null, error ? [error] : args);
|
|
||||||
} else {
|
} else {
|
||||||
throw arguments[0];
|
throw arguments[0];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user