handling of error in event loop