title: Marking an 'unhandled' web worker exception as handled
body: <p>I am trying to test some code that uses web workers. I want to check that the error path works; i.e., that an <code>onError</code> handler correctly recovers from an exception thrown in the web worker.</p>
  
  <p>The problem I'm running into is that the exception propagating out of the web worker causes it to be considered unhandled. For example, it prints in the browser's console log and causes my testing environment (a simple wrapper around Karma) to consider the test as failed.</p>
  
  <p>So, <strong>How do I indicate to the browser/Karma that an exception bubbling out of a given web worker is expected, and should not be considered unhandled?</strong> I don't want it to print to the console, and I want my test to pass.</p>
  
  <p>The only idea I've come up with is to wrap the web worker code in a try/catch and marshal the caught exception out via <code>postMessage</code>, but that requires throwing away quite a lot of information because of the need to stringify the error object (otherwise it <a href="https://stackoverflow.com/questions/7704323/passing-objects-to-a-web-worker">triggers a data clone error</a>).</p>