Fixes #2. Convert exceptions to error events.