Sha256: 1c3ca6552cbff1786fc161dc8cda5194b931884bd816e9a15c0ad10d62a7bfef

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

module Avro
  module Builder

    class RequiredAttributeError < StandardError
      def initialize(type:, attribute:, field: nil, name: nil)
        location = if field
                     "field '#{field}' of "
                   elsif name
                     "'#{name}' of "
                   end
        super("attribute :#{attribute} missing for #{location}type :#{type}")
      end
    end

    class DuplicateDefinitionError < StandardError
      def initialize(key, object, existing_object)
        super("definition for #{key.inspect} already exists\n"\
              "existing definition:\n#{to_json(existing_object)}\n"\
              "new definition:\n#{to_json(object)})")
      end

      private

      def to_json(object)
        object.to_h(SchemaSerializerReferenceState.new).to_json
      end
    end

    class DefinitionNotFoundError < StandardError
      def initialize(name)
        super("definition not found for '#{name}'.#{suggest_namespace(name)}")
      end

      private

      def suggest_namespace(name)
        ' Try specifying the full namespace.' unless name.to_s.index('.')
      end
    end

    class SchemaError < StandardError
      def initialize(actual, expected)
        super("expected schema '#{actual}' to define type '#{expected}'")
      end
    end

    AttributeError = Class.new(StandardError)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
avro-builder-0.16.1 lib/avro/builder/errors.rb
avro-builder-0.16.0 lib/avro/builder/errors.rb
avro-builder-0.15.0 lib/avro/builder/errors.rb
avro-builder-0.15.0.rc0 lib/avro/builder/errors.rb
avro-builder-0.14.1 lib/avro/builder/errors.rb
avro-builder-0.14.0 lib/avro/builder/errors.rb
avro-builder-0.13.0 lib/avro/builder/errors.rb
avro-builder-0.12.0 lib/avro/builder/errors.rb
avro-builder-0.11.0 lib/avro/builder/errors.rb
avro-builder-0.10.0 lib/avro/builder/errors.rb
avro-builder-0.9.0 lib/avro/builder/errors.rb
avro-builder-0.8.0 lib/avro/builder/errors.rb