Skip to content

error.c: Let Exception#inspect inspect its message#4857

Merged
mame merged 1 commit intoruby:masterfrom
mame:let-exception-inspect-inspects-error-message
Jun 7, 2022
Merged

error.c: Let Exception#inspect inspect its message#4857
mame merged 1 commit intoruby:masterfrom
mame:let-exception-inspect-inspects-error-message

Conversation

@mame
Copy link
Copy Markdown
Member

@mame mame commented Sep 17, 2021

p StandardError.new("foo\nbar") now prints

#<StandardError: "foo\nbar">

instead of:

#<StandardError: foo
bar>

[Bug #18170]

... only when the message string has a newline.

`p StandardError.new("foo\nbar")` now prints `#<StandardError: "foo\nbar">'
instead of:

    #<StandardError:
    bar>

[Bug #18170]
@mame mame force-pushed the let-exception-inspect-inspects-error-message branch from 641ede7 to 107d468 Compare November 30, 2021 07:28
@mame mame requested a review from nobu November 30, 2021 07:28
Copy link
Copy Markdown
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. I wonder if it would be a good idea to check for other characters (e.g. \0) as well, but I think starting with \n is fine, and that is what matz approved.

@mame mame merged commit 9d92720 into ruby:master Jun 7, 2022
st0012 added a commit to st0012/debug that referenced this pull request Jun 9, 2022
Main reason: if ruby/ruby#4857 is implemented,
using `#inspect` will lose the newlines from the formatted message.

Another reason: test frameworks usually fetch exceptions' class name
and message separately to compose the full message, instead of just
calling `#inspect`. So our test framework should be implemented
similarly.
st0012 added a commit to st0012/debug that referenced this pull request Jun 9, 2022
This will avoid tests from failing because of format changes like
ruby/ruby#4857
st0012 added a commit to st0012/debug that referenced this pull request Jun 9, 2022
This will avoid tests from failing because of format changes like
ruby/ruby#4857
st0012 added a commit to st0012/debug that referenced this pull request Jun 13, 2022
This will avoid tests from failing because of format changes like
ruby/ruby#4857
st0012 added a commit to st0012/debug that referenced this pull request Jul 5, 2022
Main reason: if ruby/ruby#4857 is implemented,
using `#inspect` will lose the newlines from the formatted message.

Another reason: test frameworks usually fetch exceptions' class name
and message separately to compose the full message, instead of just
calling `#inspect`. So our test framework should be implemented
similarly.
st0012 added a commit to st0012/debug that referenced this pull request Jul 5, 2022
This will avoid tests from failing because of format changes like
ruby/ruby#4857
ko1 pushed a commit to ruby/debug that referenced this pull request Jul 5, 2022
Main reason: if ruby/ruby#4857 is implemented,
using `#inspect` will lose the newlines from the formatted message.

Another reason: test frameworks usually fetch exceptions' class name
and message separately to compose the full message, instead of just
calling `#inspect`. So our test framework should be implemented
similarly.
ko1 pushed a commit to ruby/debug that referenced this pull request Jul 5, 2022
This will avoid tests from failing because of format changes like
ruby/ruby#4857
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants