Skip to content

Commit

Permalink
DEV: raises a GrantError instead of a log and a variable exception (#…
Browse files Browse the repository at this point in the history
…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...
```
  • Loading branch information
jjaffeux committed Apr 28, 2021
1 parent 7568c7a commit 54472e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 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
Expand Down Expand Up @@ -390,8 +391,7 @@ def self.backfill(badge, opts = nil)

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!
Expand Down

0 comments on commit 54472e4

Please sign in to comment.