Skip to content

Commit e33e44f

Browse files
committed
Slightly improved our SAFE function
1 parent 41fcc3a commit e33e44f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

jspdf.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,18 +407,17 @@ var jsPDF = (function(global) {
407407
}
408408
events.publish('addFonts', { fonts : fonts, dictionary : fontmap });
409409
},
410-
SAFE = function(fn) {
411-
fn.foo = function() {
410+
SAFE = function __safeCall(fn) {
411+
fn.foo = function __safeCallWrapper() {
412412
try {
413413
return fn.apply(this, arguments);
414414
} catch (e) {
415415
var stack = e.stack || '';
416416
if(~stack.indexOf(' at ')) stack = stack.split(" at ")[1];
417417
var m = "Error in function " + stack.split("\n")[0].split('<')[0] + ": " + e.message;
418418
if(global.console) {
419-
console.log(m, e);
419+
global.console.error(m, e);
420420
if(global.alert) alert(m);
421-
console.trace();
422421
} else {
423422
throw new Error(m);
424423
}

0 commit comments

Comments
 (0)