From: "ioquatix (Samuel Williams)" Date: 2021-11-10T11:10:39+00:00 Subject: [ruby-core:106004] [Ruby master Bug#18170] Exception#inspect should not include newlines Issue #18170 has been updated by ioquatix (Samuel Williams). Here is what I want: - `Exception.new(message).message` is always `message`. - Top level unhandled exception handler, which defaults to some well defined interface for printing exceptions. - Well defined hooks for augmenting the exception printing out process. - `Exception#inspect` should be exactly the default implementation provided by `Object#inspect`. In addition to this, in order to support printing exceptions to a format agonstic output, we need to make sure that meta-data attached to the exception is sufficiently well defined so as not to require implementation specific interfaces like `RubyVM::AST.of`. Anyway, I know that we can't have some/all of this, but I don't think it's unreasonable position to take. ---------------------------------------- Bug #18170: Exception#inspect should not include newlines https://bugs.ruby-lang.org/issues/18170#change-94552 * Author: mame (Yusuke Endoh) * Status: Assigned * Priority: Normal * Assignee: mame (Yusuke Endoh) * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Is this intentional? ``` p StandardError.new("foo\nbar") #=> # # ``` I expect `#inspect` returns a one-line string. How about returning `#` or something? Recently, multi-line error messages have been increasing by the introduction of did_you_mean and error_highlight. Printing an object that contains such an exception leads to a tricky output: ``` class Foo def initialize @exception = begin; exampl; rescue Exception; $!; end end def example end end p Foo.new #=> # # # # @exception = begin; exampl; rescue Exception; $!; end # ^^^^^^ # Did you mean? example>> ``` This issue was originally found by @ioquatix -- https://bugs.ruby-lang.org/ Unsubscribe: