Rename handle_exception to handle_job_exception
This commit is contained in:
parent
b7f45f6667
commit
5657006aca
|
@ -92,7 +92,7 @@ class SessionController < ApplicationController
|
|||
SingleSignOn::ACCESSORS.each do |a|
|
||||
details[a] = sso.send(a)
|
||||
end
|
||||
Discourse.handle_exception(e, details)
|
||||
Discourse.handle_job_exception(e, details)
|
||||
|
||||
render text: I18n.t("sso.unknown_error"), status: 500
|
||||
end
|
||||
|
|
|
@ -108,7 +108,7 @@ module Jobs
|
|||
begin
|
||||
retval = execute(opts)
|
||||
rescue => exc
|
||||
Discourse.handle_exception(exc, error_context(opts))
|
||||
Discourse.handle_job_exception(exc, error_context(opts))
|
||||
end
|
||||
return retval
|
||||
end
|
||||
|
@ -172,7 +172,7 @@ module Jobs
|
|||
|
||||
if exceptions.length > 0
|
||||
exceptions.each do |exception_hash|
|
||||
Discourse.handle_exception(exception_hash[:ex],
|
||||
Discourse.handle_job_exception(exception_hash[:ex],
|
||||
error_context(opts, exception_hash[:code], exception_hash[:other]))
|
||||
end
|
||||
raise HandledExceptionWrapper.new exceptions[0][:ex]
|
||||
|
|
|
@ -36,7 +36,7 @@ module Jobs
|
|||
message = UserNotifications.mailing_list_notify(user, post)
|
||||
Email::Sender.new(message, :mailing_list, user).send
|
||||
rescue => e
|
||||
Discourse.handle_exception(e, error_context(
|
||||
Discourse.handle_job_exception(e, error_context(
|
||||
args,
|
||||
"Sending post to mailing list subscribers", {
|
||||
user_id: user.id,
|
||||
|
|
|
@ -22,7 +22,7 @@ module Jobs
|
|||
unless UserAvatar.where("last_gravatar_download_attempt IS NULL").limit(1).first
|
||||
problems = Post.rebake_old(250)
|
||||
problems.each do |hash|
|
||||
Discourse.handle_exception(hash[:ex], error_context(args, "Rebaking post id #{hash[:post].id}", post_id: hash[:post].id))
|
||||
Discourse.handle_job_exception(hash[:ex], error_context(args, "Rebaking post id #{hash[:post].id}", post_id: hash[:post].id))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ module Jobs
|
|||
problems = UserProfile.rebake_old(250)
|
||||
problems.each do |hash|
|
||||
user_id = hash[:profile].user_id
|
||||
Discourse.handle_exception(hash[:ex], error_context(args, "Rebaking user id #{user_id}", user_id: user_id))
|
||||
Discourse.handle_job_exception(hash[:ex], error_context(args, "Rebaking user id #{user_id}", user_id: user_id))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ module Jobs
|
|||
client_message = RejectionMailer.send_rejection(message_template, message.from, template_args)
|
||||
Email::Sender.new(client_message, message_template).send
|
||||
else
|
||||
Discourse.handle_exception(e, error_context(@args, "Unrecognized error type when processing incoming email", mail: mail_string))
|
||||
Discourse.handle_job_exception(e, error_context(@args, "Unrecognized error type when processing incoming email", mail: mail_string))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,7 +89,7 @@ module Jobs
|
|||
pop.finish
|
||||
end
|
||||
rescue Net::POPAuthenticationError => e
|
||||
Discourse.handle_exception(e, error_context(@args, "Signing in to poll incoming email"))
|
||||
Discourse.handle_job_exception(e, error_context(@args, "Signing in to poll incoming email"))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ if Sidekiq.server?
|
|||
manager.tick
|
||||
rescue => e
|
||||
# the show must go on
|
||||
Discourse.handle_exception(e, {message: "While ticking scheduling manager"})
|
||||
Discourse.handle_job_exception(e, {message: "While ticking scheduling manager"})
|
||||
end
|
||||
sleep 1
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Discourse
|
|||
# error_context() method in Jobs::Base to pass the job arguments and any
|
||||
# other desired context.
|
||||
# See app/jobs/base.rb for the error_context function.
|
||||
def self.handle_exception(ex, context = {}, parent_logger = nil)
|
||||
def self.handle_job_exception(ex, context = {}, parent_logger = nil)
|
||||
context ||= {}
|
||||
parent_logger ||= SidekiqExceptionHandler
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ module Oneboxer
|
|||
}
|
||||
}
|
||||
rescue => e
|
||||
Discourse.handle_exception(e, message: "While trying to onebox a URL", url: url)
|
||||
Discourse.handle_job_exception(e, message: "While trying to onebox a URL", url: url)
|
||||
# return a blank hash, so rest of the code works
|
||||
{preview: "", onebox: ""}
|
||||
end
|
||||
|
|
|
@ -51,10 +51,10 @@ module Scheduler
|
|||
RailsMultisite::ConnectionManagement.establish_connection(db: db) if db
|
||||
job.call
|
||||
rescue => ex
|
||||
Discourse.handle_exception(ex, {message: "Running deferred code '#{desc}'"})
|
||||
Discourse.handle_job_exception(ex, {message: "Running deferred code '#{desc}'"})
|
||||
end
|
||||
rescue => ex
|
||||
Discourse.handle_exception(ex, {message: "Processing deferred code queue"})
|
||||
Discourse.handle_job_exception(ex, {message: "Processing deferred code queue"})
|
||||
ensure
|
||||
ActiveRecord::Base.connection_handler.clear_active_connections!
|
||||
end
|
||||
|
|
|
@ -42,13 +42,13 @@ module Scheduler
|
|||
def keep_alive
|
||||
@manager.keep_alive
|
||||
rescue => ex
|
||||
Discourse.handle_exception(ex, {message: "Scheduling manager keep-alive"})
|
||||
Discourse.handle_job_exception(ex, {message: "Scheduling manager keep-alive"})
|
||||
end
|
||||
|
||||
def reschedule_orphans
|
||||
@manager.reschedule_orphans!
|
||||
rescue => ex
|
||||
Discourse.handle_exception(ex, {message: "Scheduling manager orphan rescheduler"})
|
||||
Discourse.handle_job_exception(ex, {message: "Scheduling manager orphan rescheduler"})
|
||||
end
|
||||
|
||||
def process_queue
|
||||
|
@ -66,7 +66,7 @@ module Scheduler
|
|||
# Discourse.handle_exception was already called, and we don't have any extra info to give
|
||||
failed = true
|
||||
rescue => e
|
||||
Discourse.handle_exception(e, {message: "Running a scheduled job", job: klass})
|
||||
Discourse.handle_job_exception(e, {message: "Running a scheduled job", job: klass})
|
||||
failed = true
|
||||
end
|
||||
duration = ((Time.now.to_f - start) * 1000).to_i
|
||||
|
@ -77,7 +77,7 @@ module Scheduler
|
|||
@mutex.synchronize { info.write! }
|
||||
end
|
||||
rescue => ex
|
||||
Discourse.handle_exception(ex, {message: "Processing scheduled job queue"})
|
||||
Discourse.handle_job_exception(ex, {message: "Processing scheduled job queue"})
|
||||
ensure
|
||||
@running = false
|
||||
end
|
||||
|
|
|
@ -139,7 +139,7 @@ describe Discourse do
|
|||
it "should not fail when called" do
|
||||
exception = StandardError.new
|
||||
|
||||
Discourse.handle_exception(exception, nil, nil)
|
||||
Discourse.handle_job_exception(exception, nil, nil)
|
||||
expect(logger.exception).to eq(exception)
|
||||
expect(logger.context.keys).to eq([:current_db, :current_hostname])
|
||||
end
|
||||
|
@ -147,7 +147,7 @@ describe Discourse do
|
|||
it "correctly passes extra context" do
|
||||
exception = StandardError.new
|
||||
|
||||
Discourse.handle_exception(exception, {message: "Doing a test", post_id: 31}, nil)
|
||||
Discourse.handle_job_exception(exception, {message: "Doing a test", post_id: 31}, nil)
|
||||
expect(logger.exception).to eq(exception)
|
||||
expect(logger.context.keys.sort).to eq([:current_db, :current_hostname, :message, :post_id].sort)
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ describe Jobs::Base do
|
|||
raise StandardError
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it 'handles correct jobs' do
|
||||
job = GoodJob.new
|
||||
job.perform({})
|
||||
|
@ -29,9 +29,9 @@ describe Jobs::Base do
|
|||
it 'handles errors in multisite' do
|
||||
RailsMultisite::ConnectionManagement.expects(:all_dbs).returns(['default','default','default'])
|
||||
# one exception per database
|
||||
Discourse.expects(:handle_exception).times(3)
|
||||
Discourse.expects(:handle_job_exception).times(3)
|
||||
|
||||
bad = BadJob.new
|
||||
bad = BadJob.new
|
||||
expect{bad.perform({})}.to raise_error
|
||||
expect(bad.fail_count).to eq(3)
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ describe Jobs::PollMailbox do
|
|||
|
||||
Net::POP3.any_instance.expects(:start).raises(error)
|
||||
|
||||
Discourse.expects(:handle_exception)
|
||||
Discourse.expects(:handle_job_exception)
|
||||
|
||||
poller.poll_pop3
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue