Sha256: 616e37d05682159bca6c2fd5c25050563d5b9fb4766c8003bab20050cbb24be9

Contents?: true

Size: 1.38 KB

Versions: 22

Compression:

Stored size: 1.38 KB

Contents

module SparkApi
  
  # All known response codes listed in the API
  module ResponseCodes
    NOT_FOUND = 404
    METHOD_NOT_ALLOWED = 405
    INVALID_KEY = 1000
    DISABLED_KEY = 1010
    API_USER_REQUIRED = 1015
    SESSION_TOKEN_EXPIRED = 1020
    SSL_REQUIRED = 1030
    INVALID_JSON = 1035
    INVALID_FIELD = 1040
    MISSING_PARAMETER = 1050
    INVALID_PARAMETER = 1053
    CONFLICTING_DATA = 1055
    NOT_AVAILABLE= 1500
    RATE_LIMIT_EXCEEDED = 1550
  end
  
  # Errors built from API responses
  class InvalidResponse < StandardError; end
  class ClientError < StandardError
    attr_reader :code, :status, :details
    def initialize (options = {})
      # Support the standard initializer for errors
      opts = options.is_a?(Hash) ? options : {:message => options.to_s}
      @code = opts[:code]
      @status = opts[:status]
      @details = opts[:details]
      super(opts[:message])
    end
    
  end
  class NotFound < ClientError; end
  class PermissionDenied < ClientError; end
  class NotAllowed < ClientError; end
  class BadResourceRequest < ClientError; end
   
  # =Errors
  # Error messages and other error handling
  module Errors
    def self.ssl_verification_error
      "SSL verification problem: if connecting to a trusted but non production API endpoint, " + 
      "set 'ssl_verify' to false in the configuration or add '--no_verify' to the CLI command."
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
spark_api-1.3.27 lib/spark_api/errors.rb
spark_api-1.3.26 lib/spark_api/errors.rb
spark_api-1.3.25 lib/spark_api/errors.rb
spark_api-1.3.24 lib/spark_api/errors.rb
spark_api-1.3.23 lib/spark_api/errors.rb
spark_api-1.3.21 lib/spark_api/errors.rb
spark_api-1.3.20 lib/spark_api/errors.rb
spark_api-1.3.19 lib/spark_api/errors.rb
spark_api-1.3.18 lib/spark_api/errors.rb
spark_api-1.3.17 lib/spark_api/errors.rb
spark_api-1.3.16 lib/spark_api/errors.rb
spark_api-1.3.15 lib/spark_api/errors.rb
spark_api-1.3.14 lib/spark_api/errors.rb
spark_api-1.3.13 lib/spark_api/errors.rb
spark_api-1.3.10 lib/spark_api/errors.rb
spark_api-1.3.9 lib/spark_api/errors.rb
spark_api-1.3.6 lib/spark_api/errors.rb
spark_api-1.3.3 lib/spark_api/errors.rb
spark_api-1.3.1 lib/spark_api/errors.rb
spark_api-1.3.0 lib/spark_api/errors.rb