Emit an error event on exception