returning error responses to client in the event of any type of exception