Implemented error response handling