The personal finance app for everyone
Proper error handling in Sync class
Zach Gollwitzer77a2d6a048b5
diff --git a/app/models/sync.rb b/app/models/sync.rbindex cf11c313..75718d0b 100644--- a/app/models/sync.rb+++ b/app/models/sync.rb@@ -1,4 +1,6 @@class Sync < ApplicationRecord+ Error = Class.new(StandardError)+belongs_to :syncable, polymorphic: truebelongs_to :parent, class_name: "Sync", optional: true@@ -41,7 +43,7 @@ class Sync < ApplicationRecorddef handle_child_completion_eventunless has_pending_child_syncs?if has_failed_child_syncs?- fail!("One or more child syncs failed")+ fail!(Error.new("One or more child syncs failed"))elsecomplete!syncable.post_sync(self)