ruby-changes:74484
From: Yusuke <ko1@a...>
Date: Mon, 14 Nov 2022 15:06:27 +0900 (JST)
Subject: [ruby-changes:74484] 8bfd4dd4e1 (master): [ruby/error_highlight] Enable ErrorHighlight for TypeError/ArgumentError only after Ruby 3.2
https://git.ruby-lang.org/ruby.git/commit/?id=8bfd4dd4e1 From 8bfd4dd4e15a9ac3a308c3c45db629e74fae9b0c Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Mon, 14 Nov 2022 14:36:24 +0900 Subject: [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 https://github.com/ruby/ruby/blob/trunk/lib/error_highlight/core_ext.rb#L37 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 -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/