Class: Audd::ErrorResponse
- Defined in:
- lib/audd/models/error_response.rb
Overview
Envelope returned with status: "error". ResponseParser turns one of these
into the matching Audd::ApiError subclass; it is exposed because the
exception hands the parsed envelope back on #raw_response.
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#branded_message ⇒ Object
Codes 19 and 31337 may carry a "branded" artist/title instead of a real result.
- #error_code ⇒ Object
- #error_message ⇒ Object
-
#initialize(raw) ⇒ ErrorResponse
constructor
A new instance of ErrorResponse.
Methods inherited from Model
#==, #[], field, fields, from_json, #hash, #inspect, #to_h
Constructor Details
#initialize(raw) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
20 21 22 23 |
# File 'lib/audd/models/error_response.rb', line 20 def initialize(raw) super @request_params ||= raw["requested_params"] end |
Instance Method Details
#branded_message ⇒ Object
Codes 19 and 31337 may carry a "branded" artist/title instead of a real result. It is deliberately not surfaced as a recognition result.
35 36 37 38 39 40 |
# File 'lib/audd/models/error_response.rb', line 35 def return nil unless result.is_a?(Hash) parts = [result["artist"], result["title"]].compact.map(&:to_s).reject(&:empty?) parts.empty? ? nil : parts.join(" — ") end |
#error_code ⇒ Object
25 26 27 |
# File 'lib/audd/models/error_response.rb', line 25 def error_code dig_error("error_code") end |
#error_message ⇒ Object
29 30 31 |
# File 'lib/audd/models/error_response.rb', line 29 def dig_error("error_message") end |