Exception: Backblaze::RequestError

Inherits:
Error
  • Object
show all
Defined in:
lib/backblaze/errors.rb

Overview

Note:

this could be abstract, but just keeps things simple.

Basic needs for error messages.

Direct Known Subclasses

AuthError, BucketError, FileError

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ RequestError

Creates the Error

Parameters:

  • response (HTTParty::Response)

    the json response



15
16
17
# File 'lib/backblaze/errors.rb', line 15

def initialize(response)
  @response = response
end

Instance Method Details

#[](key) ⇒ Object

Shortcut to access the response keys

Returns:

  • (Object)

    the object stored at ‘key` in the response



51
52
53
# File 'lib/backblaze/errors.rb', line 51

def [](key)
  @response[key]
end

#codeString

The Backblaze B2 error code

Returns:

  • (String)

    error code



29
30
31
# File 'lib/backblaze/errors.rb', line 29

def code
  self['code']
end

#messageString

The Backblaze B2 error message which is a human explanation

Returns:

  • (String)

    the problem in human words



43
44
45
# File 'lib/backblaze/errors.rb', line 43

def message
  self['message']
end

#responseHTTParty::Response

The response from the server

Returns:

  • (HTTParty::Response)

    the response



22
23
24
# File 'lib/backblaze/errors.rb', line 22

def response
  @response
end

#statusInteger

The Backblaze B2 request status

Returns:

  • (Integer)

    status code



36
37
38
# File 'lib/backblaze/errors.rb', line 36

def status
  self['status']
end