From eb8a224fd22fd399cac5e720fd6f67f4f4f45f44 Mon Sep 17 00:00:00 2001 From: David Taylor <david@taylorhq.com> Date: Mon, 22 Jul 2024 13:15:10 +0100 Subject: [PATCH] FIX: Improve error handling for messageformat compilation (#28015) We are investigating reports of errors with messageformat compilation following 301713ef. This commit does not fix the issue, but it introduces some basic error handling to avoid completely breaking affected sites. We will have a fix for the root cause soon. --- lib/js_locale_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/js_locale_helper.rb b/lib/js_locale_helper.rb index 771984e318d..cfb85f9ddc0 100644 --- a/lib/js_locale_helper.rb +++ b/lib/js_locale_helper.rb @@ -162,6 +162,11 @@ module JsLocaleHelper #{transpiled} require("discourse-mf"); JS + rescue => e + Rails.logger.error("Failed to compile message formats for #{locale} '#{e}'") + <<~JS + console.error("Failed to compile message formats for #{locale}. Some translation strings will be missing."); + JS end def self.output_locale(locale)