lib/table_sync/errors.rb in table_sync-5.1.0 vs lib/table_sync/errors.rb in table_sync-6.0
- old
+ new
@@ -1,10 +1,39 @@
# frozen_string_literal: true
module TableSync
Error = Class.new(StandardError)
+ NoObjectsForSyncError = Class.new(Error)
+
+ class EventError < Error
+ def initialize(event)
+ super(<<~MSG.squish)
+ Event #{event.inspect} is invalid.#{' '}
+ Expected: #{TableSync::Event::VALID_RAW_EVENTS.inspect}.
+ MSG
+ end
+ end
+
+ class NoPrimaryKeyError < Error
+ def initialize(object_class, object_data, primary_key_columns)
+ super(<<~MSG.squish)
+ Can't find or init an object of #{object_class} with #{object_data.inspect}.
+ Incomplete primary key! object_data must contain: #{primary_key_columns.inspect}.
+ MSG
+ end
+ end
+
+ class NoCallableError < Error
+ def initialize(type)
+ super(<<~MSG.squish)
+ Can't find callable for #{type}!
+ Please initialize TableSync.#{type}_callable with the correct proc!
+ MSG
+ end
+ end
+
class UpsertError < Error
def initialize(data:, target_keys:, result:)
super("data: #{data.inspect}, target_keys: #{target_keys.inspect}, result: #{result.inspect}")
end
end
@@ -23,39 +52,19 @@
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
+ #:nocov:
name.to_s
+ #:nocov:
when :keyreq
"#{name}:"
when :block
"&#{name}"
end