-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add URL API to Error #1442
Add URL API to Error #1442
Conversation
Also worth considering: should the |
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.
This looks really really cool! I just have some thoughts about reducing the amount of types that are exposed, left comments inline.
Well, thinking about this a little more... The most conservative approach would be to just have |
Honesly, Totally fine with restricting it just to that! I'll make the change shortly. If we're adding |
Actually, now that I think about it, keeping On the other hand, that's technically not the URL the request failed on, so the information is less useful than the full URL. With just |
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.
Awesome, thank you!
Closes #297 by adding methods to manipulate the URL in
Error
(url_mut
,set_url
,clear_url
,without_url
, makingwith_url
public) and methods to generate formatters (as_url_masked
forUrlMaskedError
,as_url_hidden
forUrlHiddenError
,as_url_formatted
forUrlFormattedError
) which implementDisplay
on a borrowedError
.Private formatting methods for kind (
write_kind
) and source (write_source
) are added for consistency across formats, as well aswrite_url_plain
andwrite_url_masked
for different URL displays.Finally, a test was added to make sure the formatters work as expected.
See also, #1299 for prior implementation of some of these
Note: The
set_url
/clear_url
andwith_url
/without_url
pairs are a bit redundant, though the ergonomics are different. I'd be open to removing one of those pairs to make things a little simpler.