report to sentry for BadFormatRequest and ResourceNotFound exceptions
This commit is contained in:
parent
b90513f456
commit
f8b170836c
2 changed files with 9 additions and 4 deletions
|
@ -1,5 +1,14 @@
|
||||||
class ApiEntreprise::Job < ApplicationJob
|
class ApiEntreprise::Job < ApplicationJob
|
||||||
DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS = 5
|
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
|
def max_attempts
|
||||||
ENV[MAX_ATTEMPTS_API_ENTREPRISE_JOBS].to_i || DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS
|
ENV[MAX_ATTEMPTS_API_ENTREPRISE_JOBS].to_i || DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,10 +9,6 @@ class ApplicationJob < ActiveJob::Base
|
||||||
Rails.logger.info("#{job.class.name} ended at #{Time.zone.now}")
|
Rails.logger.info("#{job.class.name} ended at #{Time.zone.now}")
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue_from(ApiEntreprise::API::ResourceNotFound) do |exception|
|
|
||||||
error(self, exception)
|
|
||||||
end
|
|
||||||
|
|
||||||
def error(job, exception)
|
def error(job, exception)
|
||||||
Raven.capture_exception(exception)
|
Raven.capture_exception(exception)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue