Skip to content

Commit

Permalink
fix: error handling in Californica::Deleter (#962)
Browse files Browse the repository at this point in the history
In the delete_works loop, catch and log errors deleting individual works, continue with loop
  • Loading branch information
sourcefilter authored Apr 1, 2024
1 parent 67feb00 commit 3962be1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/lib/californica/deleter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,19 @@ def delete_collection_with_works(of_type: nil)

# Ensures all works are deleted; returns true if successful
def delete_works(of_type: nil)
total_success = true

work_id_list.empty? || work_id_list.all? do |work_id|
Californica::Deleter.new(id: work_id, logger: logger)
.delete_with_children(of_type: of_type)
begin
Californica::Deleter.new(id: work_id, logger: logger)
.delete_with_children(of_type: of_type)
rescue StandardError => e
total_success = false
log("Error deleting work #{work_id}: #{e.message}", status: :error)
end
end

total_success
end

# Modified to ensure all works are deleted before deleting the collection
Expand Down

0 comments on commit 3962be1

Please sign in to comment.