From 8bfd4dd4e15a9ac3a308c3c45db629e74fae9b0c Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 14 Nov 2022 14:36:24 +0900 Subject: [PATCH] [ruby/error_highlight] Enable ErrorHighlight for TypeError/ArgumentError only after Ruby 3.2 ... because changing TypeError#message and ArgumentError#message is highly incompatible. https://github.com/ruby/error_highlight/commit/39aa897c7a --- lib/error_highlight/core_ext.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/error_highlight/core_ext.rb b/lib/error_highlight/core_ext.rb index 00d5671648..b69093f74e 100644 --- a/lib/error_highlight/core_ext.rb +++ b/lib/error_highlight/core_ext.rb @@ -37,6 +37,11 @@ module ErrorHighlight end NameError.prepend(CoreExt) - TypeError.prepend(CoreExt) - ArgumentError.prepend(CoreExt) + + if Exception.method_defined?(:detailed_message) + # ErrorHighlight is enabled for TypeError and ArgumentError only when Exception#detailed_message is available. + # This is because changing ArgumentError#message is highly incompatible. + TypeError.prepend(CoreExt) + ArgumentError.prepend(CoreExt) + end end