Class: Spotify::Models::Error
- Inherits:
-
Object
- Object
- Spotify::Models::Error
- Defined in:
- lib/spotify/models/error.rb
Constant Summary collapse
- DEFAULT =
Identifies that the error is returned from some request.
:default
- ERRORS =
Defines the text and status for each message known.
{ timeout: { status: 700, message: "Timed out." }, unexpected_error: { status: 710, message: "Unexpected error." }, max_retries: { status: 720, message: "Max retries exceeded." }, not_available: { status: 730, message: "This feature is not available yet." }, parser_error: { status: 740, message: "Something went wrong. Please verify the parameters" } }
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
-
.default(args = {}) ⇒ Parsers::Error
Creates an error representing the site response error.
-
.max_retries ⇒ Parsers::Error
Creates an error representing that the retries limit was reached.
-
.not_available ⇒ Parsers::Error
Creates an error representing that the requested feature is not available yet.
-
.parser_error ⇒ Parsers::Error
Creates an error representing a parser error.
-
.timeout ⇒ Parsers::Error
Creates an error representing a timeout error.
-
.unexpected_error ⇒ Parsers::Error
Creates an error representing an unexpected error.
Instance Method Summary collapse
-
#initialize(type, args = {}) ⇒ Parsers::Error
constructor
Creates the message.
Constructor Details
#initialize(type, args = {}) ⇒ Parsers::Error
Creates the message.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/spotify/models/error.rb', line 47 def initialize(type, args = {}) if type == DEFAULT error = { status: args[:status], message: args[:message] } else error = ERRORS[type] end @status = error[:status] @message = error[:message] end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/spotify/models/error.rb', line 7 def @message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/spotify/models/error.rb', line 7 def status @status end |
Class Method Details
.default(args = {}) ⇒ Parsers::Error
Creates an error representing the site response error.
112 113 114 115 116 |
# File 'lib/spotify/models/error.rb', line 112 def self.default(args = {}) args = Hash(args).with_indifferent_access self.new(:default, args) end |
.max_retries ⇒ Parsers::Error
Creates an error representing that the retries limit was reached.
84 85 86 |
# File 'lib/spotify/models/error.rb', line 84 def self.max_retries self.new(:max_retries) end |
.not_available ⇒ Parsers::Error
Creates an error representing that the requested feature is not available yet.
94 95 96 |
# File 'lib/spotify/models/error.rb', line 94 def self.not_available self.new(:not_available) end |
.parser_error ⇒ Parsers::Error
Creates an error representing a parser error.
103 104 105 |
# File 'lib/spotify/models/error.rb', line 103 def self.parser_error self.new(:parser_error) end |
.timeout ⇒ Parsers::Error
Creates an error representing a timeout error.
66 67 68 |
# File 'lib/spotify/models/error.rb', line 66 def self.timeout self.new(:timeout) end |
.unexpected_error ⇒ Parsers::Error
Creates an error representing an unexpected error.
75 76 77 |
# File 'lib/spotify/models/error.rb', line 75 def self.unexpected_error self.new(:unexpected_error) end |