Implemented generic error handling.