diff --git a/app/jobs/api_entreprise/job.rb b/app/jobs/api_entreprise/job.rb index 45d21b1ad..7853100ce 100644 --- a/app/jobs/api_entreprise/job.rb +++ b/app/jobs/api_entreprise/job.rb @@ -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 diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index 767b53f1a..b914d7bd9 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -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