report to sentry for BadFormatRequest and ResourceNotFound exceptions

This commit is contained in:
Christophe Robillard 2020-06-11 23:09:50 +02:00
parent b90513f456
commit f8b170836c
2 changed files with 9 additions and 4 deletions

View file

@ -1,5 +1,14 @@
class ApiEntreprise::Job < ApplicationJob
DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS = 5
rescue_from(ApiEntreprise::API::ResourceNotFound) do |exception|
error(self, exception)
end
rescue_from(ApiEntreprise::API::BadFormatRequest) do |exception|
error(self, exception)
end
def max_attempts
ENV[MAX_ATTEMPTS_API_ENTREPRISE_JOBS].to_i || DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS
end

View file

@ -9,10 +9,6 @@ class ApplicationJob < ActiveJob::Base
Rails.logger.info("#{job.class.name} ended at #{Time.zone.now}")
end
rescue_from(ApiEntreprise::API::ResourceNotFound) do |exception|
error(self, exception)
end
def error(job, exception)
Raven.capture_exception(exception)
end