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, result) ⇒ Error

Returns a new instance of Error.



25
26
27
28
# File 'lib/gmaps_tz/error.rb', line 25

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

Instance Attribute Details

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

#uriObject

Returns the value of attribute uri.



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

def uri
  @uri
end

Class Method Details

.from_response(uri, response) ⇒ Object



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

def self.from_response(uri, response)
  json = JSON.parse(response.body)

  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, response)
end