From 1fb5e4520274b67c97b4d05dd02be0cdd2998cc6 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Fri, 24 Nov 2023 16:27:49 +0100 Subject: [PATCH] Monkey Patch Mnemosyne until Rails 7.1 support landed See https://github.com/mnemosyne-mon/mnemosyne-ruby/pull/70 --- config/initializers/monkey_patches.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/config/initializers/monkey_patches.rb b/config/initializers/monkey_patches.rb index 61c405d5..fcb0e999 100644 --- a/config/initializers/monkey_patches.rb +++ b/config/initializers/monkey_patches.rb @@ -17,3 +17,22 @@ module WillPaginate end end end + +# Required until Rails 7.1 is officially supported. +# See https://github.com/mnemosyne-mon/mnemosyne-ruby/pull/70 +module Mnemosyne + class Trace + def attach_error(error) + case error + when ActionDispatch::ExceptionWrapper + @errors << Error.new(error.exception) + when Exception + @errors << Error.new(error) + when String + @errors << Error.new(RuntimeError.new(error)) + else + raise ArgumentError.new "Invalid error type: #{error.inspect}" + end + end + end +end