Skip to content
Browse files

Catch errors setTimeout/setInterval

  • Loading branch information...
1 parent ff7ee70 commit 1a9c31083c0f53551444e08730ebf7c486410d9f @Ayms committed
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/dom.js
View
10 lib/dom.js
@@ -46,9 +46,10 @@ var dom = exports.dom = function(page,level,options) {
vm.runInContext(' \
setTimeout = (function(setTimeout_) { \
- return function(cb, timeout) { \
- if (typeof cb !== "function") cb = Function(cb); \
- return setTimeout_(cb, timeout); \
+ return function(cb, timeout) { \
+ if (typeof cb !== "function") cb = Function(cb); \
+ var db=function() {try {cb()} catch(ee) {console.log("timeout error")}}; \
+ return setTimeout_(db, timeout); \
}; \
})(setTimeout)', window);
@@ -58,7 +59,8 @@ var dom = exports.dom = function(page,level,options) {
setInterval = (function(setInterval_) { \
return function(cb, timeout) { \
if (typeof cb !== "function") cb = Function(cb); \
- return setInterval_(cb, timeout); \
+ var db=function() {try {cb()} catch(ee) {console.log("interval error")}}; \
+ return setInterval_(db, timeout); \
}; \
})(setInterval)', window);

0 comments on commit 1a9c310

Please sign in to comment.
Something went wrong with that request. Please try again.