Exception: GmapsTz::Error

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, body) ⇒ Error

Returns a new instance of Error.



23
24
25
26
# File 'lib/gmaps_tz/error.rb', line 23

def initialize(uri, body)
  @uri = uri
  @body = body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



21
22
23
# File 'lib/gmaps_tz/error.rb', line 21

def body
  @body
end

#uriObject

Returns the value of attribute uri.



21
22
23
# File 'lib/gmaps_tz/error.rb', line 21

def uri
  @uri
end

Class Method Details

.from_json(uri, json) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gmaps_tz/error.rb', line 3

def self.from_json(uri, json)
  klass = case json["status"]
          when "INVALID_REQUEST"
            InvalidRequestError
          when "OVER_QUERY_LIMIT"
            OverQueryLimitError
          when "REQUEST_DENIED"
            RequestDeniedError
          when "UNKNOWN_ERROR"
            UnknownError
          when "ZERO_RESULTS"
            ZeroResultsError
          else
            UnexpectedResponseError
          end
  klass.new(uri, json)
end