Sha256: d7f929a18ef20a90738ab028d49f6e8b9a6fcb1321afeabbefd91273af7a0077

Contents?: true

Size: 1.41 KB

Versions: 16

Compression:

Stored size: 1.41 KB

Contents

module Attributor
  class AttributorException < ::StandardError
  end

  class LoadError < AttributorException
  end

  class IncompatibleTypeError < LoadError
    def initialize(type:, value_type:, context:)
      super "Type #{type} cannot load values of type #{value_type} while loading #{Attributor.humanize_context(context)}."
    end
  end

  class CoercionError < LoadError
    def initialize(context:, from:, to:, value: nil)
      msg = "Error coercing from #{from} to #{to} while loading #{Attributor.humanize_context(context)}."
      msg += " Received value #{Attributor.errorize_value(value)}" if value
      super msg
    end
  end

  class DeserializationError < LoadError
    def initialize(context:, from:, encoding:, value: nil)
      msg = "Error deserializing a #{from} using #{encoding} while loading #{Attributor.humanize_context(context)}."
      msg += " Received value #{Attributor.errorize_value(value)}" if value
      super msg
    end
  end

  class DumpError < AttributorException
    def initialize(context:, name:, type:, original_exception:)
      msg = "Error while dumping attribute #{name} of type #{type} for context #{Attributor.humanize_context(context)}."
      msg << " Reason: #{original_exception}"
      super msg
    end
  end

  # Thrown from SmartAttributeSelector when the requirements of attributes are certainly unfeasible
  class UnfeasibleRequirementsError < AttributorException
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
attributor-8.0 lib/attributor/exceptions.rb
attributor-7.1 lib/attributor/exceptions.rb
attributor-7.0 lib/attributor/exceptions.rb
attributor-6.5 lib/attributor/exceptions.rb
attributor-6.4 lib/attributor/exceptions.rb
attributor-6.3 lib/attributor/exceptions.rb
attributor-6.2 lib/attributor/exceptions.rb
attributor-6.1 lib/attributor/exceptions.rb
attributor-6.0 lib/attributor/exceptions.rb
attributor-5.7 lib/attributor/exceptions.rb
attributor-5.6 lib/attributor/exceptions.rb
attributor-5.5 lib/attributor/exceptions.rb
attributor-5.4 lib/attributor/exceptions.rb
attributor-5.3 lib/attributor/exceptions.rb
attributor-5.2.1 lib/attributor/exceptions.rb
attributor-5.2.0 lib/attributor/exceptions.rb