From 3c63875a4294313577839a7d6a1245fa9aea77eb Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Fri, 13 Dec 2024 14:17:24 +0100 Subject: [PATCH] Fix: avoid using Marshal.dump, .load Honeybadger.context does "Local context" on its own, now. https://docs.honeybadger.io/lib/ruby/getting-started/adding-context-to-errors/ Before, this code had issues around marshaling/unmarshaling that it does not need to have. --- lib/barsoom_utils/exception_notifier.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/barsoom_utils/exception_notifier.rb b/lib/barsoom_utils/exception_notifier.rb index 41ebc90..ba28f35 100644 --- a/lib/barsoom_utils/exception_notifier.rb +++ b/lib/barsoom_utils/exception_notifier.rb @@ -37,14 +37,7 @@ def self.message(message, details_or_context = nil, context_or_nothing = nil) # Wrap this around code to add context when reporting errors. def self.run_with_context(context, &block) - # The load/dump achieves a "deep dup" without the "deep dep" of Active Support 🥁 - old_context = Marshal.load(Marshal.dump(Honeybadger.get_context)) - - Honeybadger.context(context) - block.call - ensure - Honeybadger.context.clear! - Honeybadger.context(old_context) + Honeybadger.context(context, &block) end end end