From 9bd70192b6bf2c66252c711b49dd4a6762110432 Mon Sep 17 00:00:00 2001 From: Natalie Tay Date: Mon, 11 Dec 2023 11:08:08 +0800 Subject: [PATCH] UX: Warn in /logs when PM is not sent (#271) --- plugin.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 8646250..1852de4 100644 --- a/plugin.rb +++ b/plugin.rb @@ -116,7 +116,13 @@ after_initialize do DiscourseDataExplorer::ReportGenerator.new(automation.last_updated_by_id) report_pms = data_explorer_report.generate(query_id, query_params, recipients) - report_pms.each { |pm| utils.send_pm(pm, automation_id: automation.id) } + report_pms.each do |pm| + begin + utils.send_pm(pm, automation_id: automation.id) + rescue ActiveRecord::RecordNotSaved => e + Rails.logger.warn "#{DiscourseDataExplorer::PLUGIN_NAME} - couldn't send PM for automation #{automation.id}: #{e.message}" + end + end end end end