Rethrow erors in events

Instead of manually calling window.onerror, rethrow the first error
at the end of the dispatch. This way window.onerror gets all the
expected arguments which is important for error reporters.

Fixes #408