Sha256: 5621858426c5b0b5e2380c230e3bb136f48a4a2f9baf595b4fe10a67d6ee0504

Contents?: true

Size: 1.89 KB

Versions: 9

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

module TableSync
  Error = Class.new(StandardError)

  class UpsertError < Error
    def initialize(data:, target_keys:, result:)
      super("data: #{data.inspect}, target_keys: #{target_keys.inspect}, result: #{result.inspect}")
    end
  end

  class DestroyError < Error
    def initialize(data:, target_keys:, result:)
      super("data: #{data.inspect}, target_keys: #{target_keys.inspect}, result: #{result.inspect}")
    end
  end

  class DataError < Error
    def initialize(data, target_keys, description)
      super(<<~MSG.squish)
        #{description}
        target_keys: #{target_keys}
        data: #{data}
      MSG
    end
  end

  # @api public
  # @since 2.2.0
  PluginError = Class.new(Error)

  # @api public
  # @since 2.2.0
  class UnregisteredPluginError < PluginError
    # @param plugin_name [Any]
    def initialize(plugin_name)
      super("#{plugin_name} plugin is not registered")
    end
  end

  # @api public
  # @since 2.2.0
  class AlreadyRegisteredPluginError < PluginError
    # @param plugin_name [Any]
    def initialize(plugin_name)
      super("#{plugin_name} plugin already exists")
    end
  end

  class InterfaceError < Error
    def initialize(object, method_name, parameters, description)
      parameters = parameters.map do |parameter|
        type, name = parameter

        case type
        when :req
          name.to_s
        when :keyreq
          "#{name}:"
        when :block
          "&#{name}"
        end
      end

      signature = "#{method_name}(#{parameters.join(", ")})"

      super("#{object} has to implement method `#{signature}`\n#{description}")
    end
  end

  UndefinedEvent = Class.new(Error)
  ORMNotSupported = Class.new(Error)

  class WrongOptionValue < Error
    def initialize(model, option, value)
      super("TableSync config for #{model.inspect} can't contain #{value.inspect} as #{option}")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
table_sync-5.1.0 lib/table_sync/errors.rb
table_sync-5.0.0 lib/table_sync/errors.rb
table_sync-4.2.2 lib/table_sync/errors.rb
table_sync-4.2.1 lib/table_sync/errors.rb
table_sync-4.2.0 lib/table_sync/errors.rb
table_sync-4.1.3 lib/table_sync/errors.rb
table_sync-4.1.1 lib/table_sync/errors.rb
table_sync-4.1.0 lib/table_sync/errors.rb
table_sync-4.0.0 lib/table_sync/errors.rb