Module: Workers::ErrorReportingConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/concerns/workers/error_reporting_concern.rb
Overview
Concern for Sidekiq workers that need to manually report errors
while continuing execution (e.g., batch processing).
Usage:
class MyWorker
include Sidekiq::Job
include Workers::ErrorReportingConcern
def perform(ids)
ids.each do |id|
process_item(id)
rescue StandardError => e
report_worker_error(e, item_id: id)
# Continue with next item
end
end
end
Instance Method Summary collapse
-
#report_worker_error(exception, context = {}) ⇒ Object
Report an error with worker context.
-
#report_worker_warning(message, context = {}) ⇒ Object
Report a warning with worker context.
Instance Method Details
#report_worker_error(exception, context = {}) ⇒ Object
Report an error with worker context
28 29 30 31 |
# File 'app/concerns/workers/error_reporting_concern.rb', line 28 def report_worker_error(exception, context = {}) full_context = worker_context.merge(context) ErrorReporting.error(exception, full_context) end |
#report_worker_warning(message, context = {}) ⇒ Object
Report a warning with worker context
36 37 38 39 |
# File 'app/concerns/workers/error_reporting_concern.rb', line 36 def report_worker_warning(, context = {}) full_context = worker_context.merge(context) ErrorReporting.warning(, full_context) end |