catch errors in event handlers (#254)