Sha256: a3312ea783d6ed473bce85289c16a892fd92209af0908271882c1bf79223f28a

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

module Interpol
  # Base class that interpol errors should subclass.
  class Error < StandardError; end

  # Error raised when the configuration is invalid.
  class ConfigurationError < Error
    attr_reader :original_error

    def initialize(message=nil, original_error=nil)
      @original_error = original_error
      super(message)
    end
  end

  # Error raised when data fails to validate against the schema
  # for an endpoint.
  class ValidationError < Error
    attr_reader :errors

    def initialize(errors = [], data = nil, endpoint_description = '')
      @errors = errors
      error_bullet_points = errors.map { |e| "\n  - #{e}" }.join
      message = "Found #{errors.size} error(s) when validating " +
                "against endpoint #{endpoint_description}. " +
                "Errors: #{error_bullet_points}.\n\nData:\n#{data.inspect}"

      super(message)
    end
  end

  # Error raised when the schema validator cannot find a matching
  # endpoint definition for the request.
  class NoEndpointDefinitionFoundError < Error; end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
interpol-0.0.8 lib/interpol/errors.rb
interpol-0.0.7 lib/interpol/errors.rb
interpol-0.0.6 lib/interpol/errors.rb
interpol-0.0.5 lib/interpol/errors.rb