Skip to content

Commit 39aa897

Browse files
committed
Enable ErrorHighlight for TypeError/ArgumentError only after Ruby 3.2
... because changing TypeError#message and ArgumentError#message is highly incompatible.
1 parent 59c291c commit 39aa897

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/error_highlight/core_ext.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ def to_s
3737
end
3838

3939
NameError.prepend(CoreExt)
40-
TypeError.prepend(CoreExt)
41-
ArgumentError.prepend(CoreExt)
40+
41+
if Exception.method_defined?(:detailed_message)
42+
# ErrorHighlight is enabled for TypeError and ArgumentError only when Exception#detailed_message is available.
43+
# This is because changing ArgumentError#message is highly incompatible.
44+
TypeError.prepend(CoreExt)
45+
ArgumentError.prepend(CoreExt)
46+
end
4247
end

0 commit comments

Comments
 (0)