class ABBYY::Cloud::ResponseError

Attributes

data[R]
status[R]

Public Class Methods

new(response) click to toggle source
Calls superclass method
# File lib/abbyy/cloud/exceptions/response_error.rb, line 7
def initialize(response)
  @status = response.code.to_i
  @data   = Models::Error[parse_response(response)] unless @status == 500
  super
end

Private Instance Methods

message() click to toggle source
# File lib/abbyy/cloud/exceptions/response_error.rb, line 15
    def message
      <<-MESSAGE.gsub(/ +\|/, "")
        |ABBYY Cloud API responded to the request #{data&.request_id} with a status #{status}
        |  error:       #{data&.error}
        |  description: #{data&.error_description}
        |  model_state: #{data&.model_state}
      MESSAGE
    end
parse_response(response) click to toggle source
# File lib/abbyy/cloud/exceptions/response_error.rb, line 24
def parse_response(response)
  JSON.parse(response.body)
rescue
  { error: "Server error", error_description: response.body }
end