Sha256: 1cae61b2e53948a3f101f12af1a20d63889a678523ed12b9ec332ba2b455c6b3

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

require 'dry/core/constants'

# Constants and errors common in the whole library
module ROM
  include Dry::Core::Constants

  AdapterLoadError = Class.new(StandardError)

  class AdapterNotPresentError < StandardError
    def initialize(adapter, component)
      super(
        "Failed to find #{component} class for #{adapter} adapter. " \
        "Make sure ROM setup was started and the adapter identifier is correct."
      )
    end
  end

  EnvAlreadyFinalizedError = Class.new(StandardError)
  RelationAlreadyDefinedError = Class.new(StandardError)
  MapperAlreadyDefinedError = Class.new(StandardError)
  NoRelationError = Class.new(StandardError)
  CommandError = Class.new(StandardError)
  KeyMissing = Class.new(ROM::CommandError)
  TupleCountMismatchError = Class.new(CommandError)
  UnknownPluginError = Class.new(StandardError)
  UnsupportedRelationError = Class.new(StandardError)
  MissingAdapterIdentifierError = Class.new(StandardError)

  class ElementNotFoundError < KeyError
    def initialize(key, registry)
      super(set_message(key, registry))
    end

    def set_message(key, registry)
      "#{key.inspect} doesn't exist in #{registry.class.name} registry"
    end
  end

  MapperMissingError = Class.new(ElementNotFoundError)

  CommandNotFoundError = Class.new(ElementNotFoundError) do
    def set_message(key, registry)
      "There is no :#{key} command for :#{registry.relation_name} relation"
    end
  end

  MissingSchemaClassError = Class.new(StandardError) do
    def initialize(klass)
      super("#{klass.inspect} relation is missing schema_class")
    end
  end

  MissingSchemaError = Class.new(StandardError) do
    def initialize(klass)
      super("#{klass.inspect} relation is missing schema definition")
    end
  end

  DuplicateConfigurationError = Class.new(StandardError)
  DuplicateContainerError = Class.new(StandardError)

  InvalidOptionValueError = Class.new(StandardError)
  InvalidOptionKeyError = Class.new(StandardError)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-core-4.0.0.beta2 lib/rom/constants.rb
rom-core-4.0.0.beta1 lib/rom/constants.rb