Sha256: 3bde643504db09a612abb6e08abc30c1302e3c4d7982b709f475fa0866bd3b91

Contents?: true

Size: 686 Bytes

Versions: 4

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

require 'dry/plugins/error'

module Dry
  module Plugins
    class Registry
      # Plug-in registration error
      class KeyError < Error
        def initialize(registry, key, plugin)
          super <<~ERROR
            Cannot register #{key.inspect} in #{registry.inspect}
              as
                #{indent plugin.inspect}
              since previously registered
                #{indent registry[key].inspect}
          ERROR
        end

        private

        def indent(lines, indentation: ' ' * 4, glue: "\n")
          indentation + lines.to_s.split(/\n/).join("#{indentation}#{glue}") + glue
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-plugins-0.4.0 lib/dry/plugins/registry/key_error.rb
dry-plugins-0.3.0 lib/dry/plugins/registry/key_error.rb
dry-plugins-0.2.0 lib/dry/plugins/registry/key_error.rb
dry-plugins-0.1.0 lib/dry/plugins/registry/key_error.rb