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.



6
7
8
9
# File 'lib/yt/errors/request_error.rb', line 6

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

Instance Method Details

#kindObject



18
19
20
# File 'lib/yt/errors/request_error.rb', line 18

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

#messageObject



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

#reasonsObject



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

def reasons
  case kind
    when Hash then kind.fetch('errors', []).map{|e| e['reason']}
    else kind
  end
end