Sha256: 6576c15ee8b9e6135305f9fe4593a5aafeed78caab70194be01b6fadb60f2f17

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module Europeana
  module API
    module Errors
      ##
      # Raised if API requests are attempted without the API key having been set.
      #
      # @todo Use one-line error messages (in backwards-incompatible version)
      class MissingAPIKeyError < StandardError
        def initialize(msg = nil)
          msg ||= <<-MSG
  Missing API key.

  The Europeana API key has not been set.

  Sign up for an API key at: http://labs.europeana.eu/api/registration/

  Set the key with:

    Europeana::API.api_key = "xyz"
          MSG
          super(msg)
        end
      end

      ##
      # Raised if the API response success flag is false, indicating a problem
      # with the request.
      class RequestError < StandardError
        def initialize(msg = nil)
          msg ||= <<-MSG
  Request error.

  There was a problem with your request to the Europeana API.
          MSG
          super(msg)
        end
      end

      ##
      # Raised if the API response is not valid JSON.
      class ResponseError < StandardError
        def initialize(msg = nil)
          msg ||= <<-MSG
  Response error.

  Unable to parse the response from the Europeana API.
          MSG
          super(msg)
        end
      end

      module Request
        ##
        # Raised if the API response indicates invalid pagination params in
        # the request.
        class PaginationError < StandardError
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
europeana-api-0.5.2 lib/europeana/api/errors.rb
europeana-api-0.5.0 lib/europeana/api/errors.rb
europeana-api-0.4.3 lib/europeana/api/errors.rb