FIX: show available details when rescuing error

FIX: show available details when rescuing error

diff --git a/lib/tasks/avatars.rake b/lib/tasks/avatars.rake
index af03fd5..b53b6e4 100644
--- a/lib/tasks/avatars.rake
+++ b/lib/tasks/avatars.rake
@@ -32,7 +32,7 @@ task "avatars:clean" => :environment do
     begin
       optimized_image.destroy!
     rescue => e
-      puts "", "Failed to cleanup avatar for #{user.username}", e, e.backtrace.join("\n")
+      puts "", "Failed to cleanup avatar (optimized_image_id: #{optimized_image.id}, optimized_image_url: #{optimized_image.url})", e, e.backtrace.join("\n")
     end
     putc "." if (i += 1) % 10 == 0
   end

GitHub sha: 989325ea

I think I am becoming less of a fan of find_each, I think there are some weird transactional things that can happen that we saw in a previous job.

Can you change it so you pluck the ids, then do a find_by for each id, if it is missing skip otherwise try and handle the error.

2 Likes

Done in:

1 Like