DEV: raises a GrantError instead of a log and a variable exception (#12875)

DEV: raises a GrantError instead of a log and a variable exception (#12875)

The message in logs will now look like:

BadgeGranter::GrantError: Failed to backfill 'Some Badge' badge: {:post_ids=>[]}. Reason: ERROR:  column "email" does not exist
LINE 6: ...t id as user_id, current_timestamp as granted_at, email from...
diff --git a/app/services/badge_granter.rb b/app/services/badge_granter.rb
index 1d52ea6..96dec02 100644
--- a/app/services/badge_granter.rb
+++ b/app/services/badge_granter.rb
@@ -1,6 +1,7 @@
 # frozen_string_literal: true
 
 class BadgeGranter
+  class GrantError < StandardError; end
 
   def self.disable_queue
     @queue_disabled = true
@@ -390,8 +391,7 @@ class BadgeGranter
 
     badge.reset_grant_count!
   rescue => e
-    Rails.logger.error("Failed to backfill '#{badge.name}' badge: #{opts}")
-    raise e
+    raise GrantError, "Failed to backfill '#{badge.name}' badge: #{opts}. Reason: #{e.message}"
   end
 
   def self.revoke_ungranted_titles!

GitHub sha: 54472e41

This commit appears in #12875 which was approved by davidtaylorhq. It was merged by jjaffeux.