Exception: Yt::Errors::RequestError
- Inherits:
-
StandardError
- Object
- StandardError
- Yt::Errors::RequestError
show all
- Defined in:
- lib/yt/errors/request_error.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of RequestError.
6
7
8
9
|
# File 'lib/yt/errors/request_error.rb', line 6
def initialize(msg = {})
@msg = msg
super msg
end
|
Instance Method Details
#description ⇒ Object
22
23
24
|
# File 'lib/yt/errors/request_error.rb', line 22
def description
response_body.fetch 'error_description', {}
end
|
#explanation ⇒ Object
33
34
35
|
# File 'lib/yt/errors/request_error.rb', line 33
def explanation
'A request to YouTube API failed'
end
|
#kind ⇒ Object
18
19
20
|
# File 'lib/yt/errors/request_error.rb', line 18
def kind
response_body.fetch 'error', {}
end
|
#message ⇒ Object
11
12
13
14
15
16
|
# File 'lib/yt/errors/request_error.rb', line 11
def message
<<-MSG.gsub(/^ {8}/, '')
#{explanation}:
#{Yt.configuration.debugging? ? details : no_details }
MSG
end
|
#reasons ⇒ Object
26
27
28
29
30
31
|
# File 'lib/yt/errors/request_error.rb', line 26
def reasons
case kind
when Hash then kind.fetch('errors', []).map{|e| e['reason']}
else kind
end
end
|
#response_body ⇒ Object
37
38
39
|
# File 'lib/yt/errors/request_error.rb', line 37
def response_body
json['response_body'].is_a?(Hash) ? json['response_body'] : {}
end
|