title: Global JavaScript exception handler (in Chrome)
body: <p>How do I overwrite the global Exception handler in JavaScript so that it becomes the top level handler for all uncaught exceptions?</p>
  <p><em>window.onerror</em> didn’t work. The code is:</p>
  <pre><code>&lt;HTML&gt;
      &lt;HEAD&gt;
          &lt;script language='javascript'&gt;
              window.onerror = function (em, url, ln) {
                  alert(em + &quot;, &quot; + url + &quot;, &quot; + ln);
                  return false;
              }
  
              function fGo() {
                  try
                  {
                      var a = b; // Error here: b not defined
                  }
                  catch (e)
                  {
                      throw e;
                  }
              }
          &lt;/script&gt;
      &lt;/HEAD&gt;
  
      &lt;BODY&gt;
          &lt;button onclick='fGo()'&gt;GO&lt;/button&gt;
      &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  <p>I'm testing on Chrome, by the way. The developer console registers the uncaught exception, but the alert() in <em>window.onerror</em> does not appear.</p>