def initialize(request_url, errmsg)
@request_url = request_url
@api_response ||= {}
+ errors = @api_response[:errors]
+ if not errors.is_a?(Array)
+ @api_response[:errors] = [errors || errmsg]
+ end
super(errmsg)
end
end
+ class NoApiResponseException < ApiError
+ def initialize(request_url, exception)
+ @api_response_s = exception.to_s
+ super(request_url,
+ "#{exception.class.to_s} error connecting to API server")
+ end
+ end
class InvalidApiResponseException < ApiError
def initialize(request_url, api_response)
profile_checkpoint { "Prepare request #{url} #{query[:uuid]} #{query[:where]} #{query[:filters]}" }
msg = @client_mtx.synchronize do
- @api_client.post(url,
- query,
- header: header)
+ begin
+ @api_client.post(url, query, header: header)
+ rescue => exception
+ raise NoApiResponseException.new(url, exception)
+ end
end
profile_checkpoint 'API transaction'
if not resp.is_a? Hash
raise InvalidApiResponseException.new(url, msg)
elsif msg.status_code != 200
- error_class = ERROR_CODE_CLASSES.fetch(msg.status_code, ApiError)
+ error_class = ERROR_CODE_CLASSES.fetch(msg.status_code,
+ ApiErrorResponseException)
raise error_class.new(url, msg)
end