title: javascript: skip a specific thrown error
body: <p>I have a page which includes a js-file. It's a jquery Plugin, but I think thats not important. The plugin break with a manually thrown error at one point.</p>
  
  <pre><code>(function($) {
      $.pkp.classes.Handler = function($element, options) {
          /* ... */
  
          if (this.data('handler') !== undefined) {
              throw new Error('blub');
          }
  </code></pre>
  
  <p>If I remove the line it works perfektly, so I think the check is not necessary. Unfortunatley I can not change the js-file (it would get overwritten every update), but I could savely include another one.</p>
  
  <p>I tried to catch the error and let the script continue untouched as if the error throwing line where deleted.</p>
  
  <pre><code>$(window).error(function(e){
      var t = 'Handler.js';
      var l = t.length;
      var file =     e.originalEvent.filename.substr(e.originalEvent.filename.length - l, l);
  
      if ((e.originalEvent.lineno == 38) &amp;&amp; (file == t)) {
          e.preventDefault();
          return true;
      }
  </code></pre>
  
  <p>})</p>
  
  <p>I tried something similar with window.onerror. The result is, that in both cases the error doesn't appear, but the script does not continue as it would, if the line was deleted.</p>
  
  <p>I know it would be better to find the source of the misbehaviour but its a very complicates bunch of scripts, and everything works still perfectly after I put a newer jQuery and a migration script there - only this single line makes problems, so I thought maybe it's more efficient just to eliminate the error without understanding it completely...</p>
  
  <p>Any suggestions?</p>