Log error stacktrace only when available

Safari does not provide a `stack` property on Error instances.
This commit is contained in:
Ionuț G. Stan 2011-10-28 14:27:41 +03:00
parent 0c321466dc
commit 009d6a8863

5
pdf.js
View File

@ -22,16 +22,15 @@ function warn(msg) {
}
function backtrace() {
var stackStr;
try {
throw new Error();
} catch (e) {
stackStr = e.stack;
return e.stack ? e.stack.split('\n').slice(2).join('\n') : "";
}
return stackStr.split('\n').slice(1).join('\n');
}
function error(msg) {
log("Error: " + msg);
log(backtrace());
throw new Error(msg);
}