h2non/thread.js

View on GitHub
examples/error.html

Summary

Maintainability
Test Coverage
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <script src="../thread.js"></script>
    <script>
      var worker = thread({
        env: { error: true }
      })

      // throwing an error
      var task = worker.run(function (done) {
        if (env.error)
          throw new Error('invalid')
      })

      task['catch'](function (err) {
        console.log('Error:', err)
      })

      // returning an error
      var task2 = worker.run(function () {
        if (env.error)
          return new Error('invalid')
      })

      task2['catch'](function (err) {
        console.log('Error:', err)
      })

    </script>
  </body>
</html>