Skip to content

Commit

Permalink
exceptions wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraghiorghisor-tw authored and minhngocd committed Dec 5, 2024
1 parent 4202eee commit 0fbadf9
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 147 deletions.
15 changes: 9 additions & 6 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ namespace :assets do
delete_and_update_draft(replacement_asset)
processed_asset_ids[replacement_asset.id.to_s] = true
puts "Asset ID: #{original_asset_id} - OK. Draft replacement #{replacement_asset.id} deleted and updated to false."
rescue StandardError
puts "Asset ID: #{original_asset_id} - ERROR. Asset replacement failed to save. Error: #{replacement_asset.errors.full_messages}."
rescue StandardError => e
message = replacement_asset.errors.full_messages.empty? ? e.message : replacement_asset.errors.full_messages
puts "Asset ID: #{original_asset_id} - ERROR. Asset replacement #{replacement_asset.id} failed to save. Error: #{message}."
end
next
end
Expand All @@ -91,8 +92,9 @@ namespace :assets do
delete_and_update_draft(original_asset)
processed_asset_ids[original_asset_id] = true
puts "Asset ID: #{original_asset_id} - OK. Asset is a replacement. Asset deleted and updated to false."
rescue StandardError
puts "Asset ID: #{original_asset_id} - ERROR. Asset failed to save. Error: #{original_asset.errors.full_messages}."
rescue StandardError => e
message = original_asset.errors.full_messages.empty? ? e.message : original_asset.errors.full_messages
puts "Asset ID: #{original_asset_id} - ERROR. Asset failed to save. Error: #{message}."
end
next
end
Expand All @@ -111,8 +113,9 @@ namespace :assets do
delete_and_update_draft(original_asset, should_update_draft: false)
processed_asset_ids[original_asset_id] = true
puts "Asset ID: #{original_asset_id} - OK. Asset has been deleted."
rescue StandardError
puts "Asset ID: #{original_asset_id} - ERROR. Asset failed to save. Error: #{original_asset.errors.full_messages}."
rescue StandardError => e
message = original_asset.errors.full_messages.empty? ? e : original_asset.errors.full_messages
puts "Asset ID: #{original_asset_id} - ERROR. Asset failed to save. Error: #{message}."
end
end
end
Expand Down
Loading

0 comments on commit 0fbadf9

Please sign in to comment.