diff --git a/CHANGELOG b/CHANGELOG index a980cdb..22e8b2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -* Re-throw error in otherwise-empty `catch` clause so that `PeriodicalExecuter` does not suppress exceptions. (Samuel Lebeau) +* Fix `PeriodicalExecuter` so that it no longer suppresses exceptions. [#696 state:resolved] (Samuel Lebeau, Yaffle) * Fix issue related to escaping of selectors for querySelectorAll. [#559 state:resolved] (Jorn Holm) diff --git a/src/lang/periodical_executer.js b/src/lang/periodical_executer.js index aca00f8..e521bbf 100644 --- a/src/lang/periodical_executer.js +++ b/src/lang/periodical_executer.js @@ -49,15 +49,20 @@ var PeriodicalExecuter = Class.create({ onTimerEvent: function() { if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.execute(); - } catch(e) { - // Catch clause for clients that don't support try/finally. - throw e; - } - finally { - this.currentlyExecuting = false; + if (!this.currentlyExecuting) { + // IE doesn't support `finally` statements unless all errors are caught. + // We mimic the behaviour of `finally` statements by duplicating code + // that would belong in it. First at the bottom of the `try` statement + // (for errorless cases). Secondly, inside a `catch` statement which + // rethrows any caught errors. + try { + this.currentlyExecuting = true; + this.execute(); + this.currentlyExecuting = false; + } catch(e) { + this.currentlyExecuting = false; + throw e; + } } } }