Exception: Geoloqi::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/geoloqi/error.rb

Overview

Used for Geoloqi API errors (errors originating from the API server itself).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, type, reason = nil) ⇒ ApiError

Instantiate a new ApiError object



24
25
26
27
28
29
30
31
32
# File 'lib/geoloqi/error.rb', line 24

def initialize(status, type, reason=nil)
  @status = status
  @type = type
  @reason = reason
  message = type
  message += " - #{reason}" if reason
  message += " (#{status})"
  super message
end

Instance Attribute Details

#reasonString (readonly)

Human-readable explanation of error.

Examples:

"The requested resource could not found"

Returns:

  • (String)


20
21
22
# File 'lib/geoloqi/error.rb', line 20

def reason
  @reason
end

#statusFixnum (readonly)

Status code of error

Examples:

404, 500

Returns:

  • (Fixnum)


8
9
10
# File 'lib/geoloqi/error.rb', line 8

def status
  @status
end

#typeString (readonly)

Type of error

Examples:

"not_found", "invalid_input"

Returns:

  • (String)


14
15
16
# File 'lib/geoloqi/error.rb', line 14

def type
  @type
end