diff --git a/app/jobs/scheduled/check_out_of_date_themes.rb b/app/jobs/scheduled/check_out_of_date_themes.rb index 35592292c7b..11ec149e947 100644 --- a/app/jobs/scheduled/check_out_of_date_themes.rb +++ b/app/jobs/scheduled/check_out_of_date_themes.rb @@ -11,8 +11,10 @@ module Jobs .where.not(remote_url: "") target_themes.each do |remote| - remote.update_remote_version - remote.save! + Discourse.capture_exceptions(message: "Error updating theme #{remote.id}") do + remote.update_remote_version + remote.save! + end end end end diff --git a/lib/discourse.rb b/lib/discourse.rb index caba3ba4cef..acb8d2060d5 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -932,6 +932,13 @@ module Discourse STDERR.puts "Failed to report exception #{e} #{message}" end + def self.capture_exceptions(message: "", env: nil) + yield + rescue Exception => e + Discourse.warn_exception(e, message: message, env: env) + nil + end + def self.deprecate(warning, drop_from: nil, since: nil, raise_error: false, output_in_test: false) location = caller_locations[1].yield_self { |l| "#{l.path}:#{l.lineno}:in \`#{l.label}\`" } warning = ["Deprecation notice:", warning]