Module: Scorpio::Ur
- Defined in:
- lib/scorpio/ur.rb
Instance Attribute Summary collapse
-
#scorpio_request ⇒ Object
Returns the value of attribute scorpio_request.
Instance Method Summary collapse
-
#raise_on_http_error ⇒ void
raises a subclass of Scorpio::HTTPError if the response has an error status.
Instance Attribute Details
#scorpio_request ⇒ Object
Returns the value of attribute scorpio_request.
18 19 20 |
# File 'lib/scorpio/ur.rb', line 18 def scorpio_request @scorpio_request end |
Instance Method Details
#raise_on_http_error ⇒ void
This method returns an undefined value.
raises a subclass of Scorpio::HTTPError if the response has an error status. raises nothing if the status is 2xx. raises ClientError or one of its response-specific subclasses if the status is 4xx. raises ServerError or one of its response-specific subclasses if the status is 5xx. raises a generic HTTPError otherwise.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/scorpio/ur.rb', line 28 def raise_on_http_error error_class = Scorpio.error_classes_by_status[response.status] error_class ||= if (400..499).include?(response.status) ClientError elsif (500..599).include?(response.status) ServerError elsif !response.success? HTTPError end if error_class = "Error calling operation #{scorpio_request.operation.human_id}:\n" + response.body raise(error_class.new().tap do |e| e.ur = self e.response_object = response.body_object end) end nil end |