Sha256: 32c9534302ae0e202ab9d724357d0b6c83f3d62759235b410b8be7dbd7672833

Contents?: true

Size: 906 Bytes

Versions: 4

Compression:

Stored size: 906 Bytes

Contents

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

  # Error raised when the configuration is invalid.
  class ConfigurationError < Error; 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.4 lib/interpol/errors.rb
interpol-0.0.3 lib/interpol/errors.rb
interpol-0.0.2 lib/interpol/errors.rb
interpol-0.0.1 lib/interpol/errors.rb