Sha256: 80a0f82153d2b9b534d52ad67e5f25118286eb255cdfd692f6181e08ef0eb442

Contents?: true

Size: 554 Bytes

Versions: 2

Compression:

Stored size: 554 Bytes

Contents

module GeoNamesAPI
  class Error < StandardError
    # See http://www.geonames.org/export/webservice-exception.html
    def self.from_status(status)
      val = status['value'].to_i
      error_type = case val
        when 12, 13, 22
          Timeout
        when 14
          InvalidParameter
        when 21
          InvalidInput
        else
          Error
      end
      raise error_type, "#{status['message']} (#{val})"
    end
  end

  class Timeout < Error
  end

  class InvalidParameter < Error
  end

  class InvalidInput < Error
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geonames_api-0.1.1 lib/geonames_api/error.rb
geonames_api-0.1.0 lib/geonames_api/error.rb