Exception: Yt::Errors::RequestError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/yt/errors/request_error.rb

Direct Known Subclasses

Forbidden, MissingAuth, NoItems, ServerError, Unauthorized

Instance Method Summary collapse

Constructor Details

#initialize(msg = {}) ⇒ RequestError

Returns a new instance of RequestError.



4
5
6
7
# File 'lib/yt/errors/request_error.rb', line 4

def initialize(msg = {})
  @msg = msg
  super msg
end

Instance Method Details

#kindObject



20
21
22
# File 'lib/yt/errors/request_error.rb', line 20

def kind
  response_body.fetch 'error', {}
end

#messageObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/yt/errors/request_error.rb', line 9

def message
  <<-MSG.gsub(/^ {8}/, '')
  #{explanation}:
  #{response_body}

  You can retry the same request manually by running:
  #{request_curl}
  #{more_details}
  MSG
end

#reasonsObject



24
25
26
# File 'lib/yt/errors/request_error.rb', line 24

def reasons
  kind.fetch('errors', []).map{|e| e['reason']}
end