From 77a2d6a048b52214521f71e0fd88e660455c198a Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Fri, 18 Apr 2025 09:46:49 -0400 Subject: [PATCH] Proper error handling in Sync class --- app/models/sync.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/sync.rb b/app/models/sync.rb index 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: true belongs_to :parent, class_name: "Sync", optional: true @@ -41,7 +43,7 @@ class Sync < ApplicationRecord def handle_child_completion_event unless 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")) else complete! syncable.post_sync(self)