diff --git a/app/jobs/base.rb b/app/jobs/base.rb index db6ed11ef..3ababe086 100644 --- a/app/jobs/base.rb +++ b/app/jobs/base.rb @@ -67,7 +67,7 @@ module Jobs ctx = {} ctx[:opts] = opts ctx[:job] = self.class - ctx[:code] = code_desc if code_desc + ctx[:message] = code_desc if code_desc ctx.merge!(extra) if extra != nil ctx end @@ -157,7 +157,7 @@ module Jobs end rescue => e thread_exception[:ex] = e - thread_exception[:code] = "establishing database connection to #{db}" + thread_exception[:message] = "While establishing database connection to #{db}" thread_exception[:other] = { problem_db: db } ensure ActiveRecord::Base.connection_handler.clear_active_connections! diff --git a/app/jobs/scheduled/poll_mailbox.rb b/app/jobs/scheduled/poll_mailbox.rb index 05c5da4ec..07d166fe8 100644 --- a/app/jobs/scheduled/poll_mailbox.rb +++ b/app/jobs/scheduled/poll_mailbox.rb @@ -48,7 +48,7 @@ module Jobs client_message = RejectionMailer.send_rejection(message.from, message.body, message.to, message_template) Email::Sender.new(client_message, message_template).send else - Discourse.handle_exception(e, error_context(@args, "unknown error when processing incoming email", mail: mail_string)) + Discourse.handle_exception(e, error_context(@args, "Unrecognized error type when processing incoming email", mail: mail_string)) end ensure mail.delete diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index df5662f30..5a8055cb0 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -33,7 +33,7 @@ if Sidekiq.server? manager.tick rescue => e # the show must go on - Discourse.handle_exception(e, {code: "Ticking scheduling manager"}) + Discourse.handle_exception(e, {message: "While ticking scheduling manager"}) end sleep 1 end diff --git a/lib/oneboxer.rb b/lib/oneboxer.rb index 2b073d910..8bb9693b4 100644 --- a/lib/oneboxer.rb +++ b/lib/oneboxer.rb @@ -128,7 +128,7 @@ module Oneboxer } } rescue => e - Discourse.handle_exception(e, url: url) + Discourse.handle_exception(e, message: "While trying to onebox a URL", url: url) # return a blank hash, so rest of the code works {preview: "", onebox: ""} end diff --git a/lib/scheduler/defer.rb b/lib/scheduler/defer.rb index d9587302d..cac1ca897 100644 --- a/lib/scheduler/defer.rb +++ b/lib/scheduler/defer.rb @@ -51,10 +51,10 @@ module Scheduler RailsMultisite::ConnectionManagement.establish_connection(db: db) job.call rescue => ex - Discourse.handle_exception(ex, {code: "Running deferred code '#{desc}'"}) + Discourse.handle_exception(ex, {message: "Running deferred code '#{desc}'"}) end rescue => ex - Discourse.handle_exception(ex, {code: "Processing deferred code queue"}) + Discourse.handle_exception(ex, {message: "Processing deferred code queue"}) ensure ActiveRecord::Base.connection_handler.clear_active_connections! end diff --git a/lib/scheduler/manager.rb b/lib/scheduler/manager.rb index f77a83b5c..9102091ef 100644 --- a/lib/scheduler/manager.rb +++ b/lib/scheduler/manager.rb @@ -42,13 +42,13 @@ module Scheduler def keep_alive @manager.keep_alive rescue => ex - Discourse.handle_exception(ex, {code: "Scheduling manager keep-alive"}) + Discourse.handle_exception(ex, {message: "Scheduling manager keep-alive"}) end def reschedule_orphans @manager.reschedule_orphans! rescue => ex - Discourse.handle_exception(ex, {code: "Scheduling manager orphan rescheduler"}) + Discourse.handle_exception(ex, {message: "Scheduling manager orphan rescheduler"}) end def process_queue @@ -63,10 +63,10 @@ module Scheduler @mutex.synchronize { info.write! } klass.new.perform rescue Jobs::HandledExceptionWrapper - # Discourse.handle_exception was already called + # Discourse.handle_exception was already called, and we don't have any extra info to give failed = true rescue => e - Discourse.handle_exception(e, {code: "Running a scheduled job", job: klass}) + Discourse.handle_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, {code: "Processing scheduled job queue"}) + Discourse.handle_exception(ex, {message: "Processing scheduled job queue"}) ensure @running = false end diff --git a/spec/components/discourse_spec.rb b/spec/components/discourse_spec.rb index 819732eb3..f18dde916 100644 --- a/spec/components/discourse_spec.rb +++ b/spec/components/discourse_spec.rb @@ -144,9 +144,9 @@ describe Discourse do it "correctly passes extra context" do exception = StandardError.new - Discourse.handle_exception(exception, {code: "Doing a test", post_id: 31}, nil) + Discourse.handle_exception(exception, {message: "Doing a test", post_id: 31}, nil) logger.exception.should == exception - logger.context.keys.sort.should == [:current_db, :current_hostname, :code, :post_id].sort + logger.context.keys.sort.should == [:current_db, :current_hostname, :message, :post_id].sort end end