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 Attribute Summary collapse

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 Attribute Details

#responseHTTParty::Response (readonly)

The response from the server

Returns:

  • (HTTParty::Response)

    the response



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

def response
  @response
end

Instance Method Details

#[](key) ⇒ Object

Shortcut to access the response keys

Returns:

  • (Object)

    the object stored at ‘key` in the response



48
49
50
# File 'lib/backblaze/errors.rb', line 48

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

#codeString

The Backblaze B2 error code

Returns:

  • (String)

    error code



27
28
29
# File 'lib/backblaze/errors.rb', line 27

def code
  self['code']
end

#messageString

The Backblaze B2 error message which is a human explanation

Returns:

  • (String)

    the problem in human words



41
42
43
# File 'lib/backblaze/errors.rb', line 41

def message
  self['message']
end

#statusInteger

The Backblaze B2 request status

Returns:

  • (Integer)

    status code



34
35
36
# File 'lib/backblaze/errors.rb', line 34

def status
  self['status']
end