Sha256: d538184f7a220e8314128cf79d46d952a5537466d548462f10fe082e531e1a83

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

module GmapsTz
  class Error < StandardError
    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

    attr_accessor :uri, :body

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

  class InvalidRequestError < Error; end

  class OverQueryLimitError < Error; end

  class RequestDeniedError < Error; end

  class UnknownError < Error; end

  class ZeroResultsError < Error; end

  class InvalidResponseBodyError < Error; end

  class UnexpectedResponseError < Error; end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gmaps_tz-0.0.4 lib/gmaps_tz/error.rb
gmaps_tz-0.0.3 lib/gmaps_tz/error.rb
gmaps_tz-0.0.2 lib/gmaps_tz/error.rb