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...
```
This commit is contained in:
Joffrey JAFFEUX 2021-04-28 20:05:45 +02:00 committed by GitHub
parent 7568c7a101
commit 54472e4150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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!