This effectively implements Worker.onerror, and in future SharedWorker.onerror. (cherry picked from commit 3440d2b843331fca7392d29ea1b776935d1310de)