Exception: KinopoiskUnofficialApi::Exceptions::ResponseError
- Defined in:
- lib/kinopoisk_unofficial_api/exceptions/response_error.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #data ⇒ Object
- #error_code ⇒ Object
- #error_message ⇒ Object
-
#initialize(response:) ⇒ ResponseError
constructor
A new instance of ResponseError.
Constructor Details
#initialize(response:) ⇒ ResponseError
Returns a new instance of ResponseError.
8 9 10 11 12 |
# File 'lib/kinopoisk_unofficial_api/exceptions/response_error.rb', line 8 def initialize(response:) @response = response super("Kinopoisk Unofficial API has returned the error. (#{error_data_dump})") end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/kinopoisk_unofficial_api/exceptions/response_error.rb', line 6 def response @response end |
Instance Method Details
#data ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/kinopoisk_unofficial_api/exceptions/response_error.rb', line 22 def data @data ||= begin JSON.parse(response.body) rescue JSON::ParserError { error_code: response.status, uri: response.env.url.to_s } end end |
#error_code ⇒ Object
14 15 16 |
# File 'lib/kinopoisk_unofficial_api/exceptions/response_error.rb', line 14 def error_code response.status end |
#error_message ⇒ Object
18 19 20 |
# File 'lib/kinopoisk_unofficial_api/exceptions/response_error.rb', line 18 def data[:message] || data["message"] end |