-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[stdlib] Add Error.as_string_slice() and polish
#4304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ), | ||
| ")", | ||
| ) | ||
| return String("Error(", repr(self.as_string_slice()), ")") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the repr necessary (can we make it "Error('" etc.)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't like building a String unnecessarily, but I don't know whether to remove this. It adds " to the end and beginning of the message or ' if the message contains ", it also encodes control characters in the ASCII range. Since it encodes those characters instead of printing, I think it's worth it in cases where you would want to print something that might have been corrupted on the way. But I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Maybe we should make repr return a different Writable than String in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe once we have some API for streaming a repr i.e. __repr__(self, mut writer: Writer)
92a9cad to
b97aded
Compare
laszlokindrat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Could you please fix the conflicts so I can bring this in?
b97aded to
263b19f
Compare
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
263b19f to
e747213
Compare
|
@laszlokindrat done :) |
|
!sync |
|
✅🟣 This contribution has been merged 🟣✅ Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the main branch during the next Mojo nightly release, typically within the next 24-48 hours. We use Copybara to merge external contributions, click here to learn more. |
|
Landed in bc05a00! Thank you for your contribution 🎉 |
Add
Error.as_string_slice()and polish