-
Notifications
You must be signed in to change notification settings - Fork 335
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
Replace ()
error types with specific types that implement Error
#299
Comments
Yep we struggled with this in #323. It makes it hard to handle these errors concisely. |
Here's a list of public methods returning
Although I would have suggested a Methods 7 and 8 could return a new variant Let's not also forget |
Replace unwrap() in doctests with `?` Fixes #312. - All results yielding `ParseError` in the doctests should now be handled with the ? operator. - Some other specific results are ~unwrapped with `expect()`~ mapped to a placeholder string message, such as in URLs that are not _cannot-be-a-base_. Users are then expected to adjust this mapping depending on their use case. Once #299 is resolved, we'll be able to propagate these normally. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/323) <!-- Reviewable:end -->
I'll start working on this. |
This is an initial pass at servo#299. It does not change `ParseError` to the more idiomatic `Error` name, or change `with_default_port`'s return type.
1 to 6 don't exactly have the same error conditions, actually.
|
I guess for 4-6 we could return |
In my PR I went with |
This is an initial pass at servo#299. It does not change `ParseError` to the more idiomatic `Error` name, or change `with_default_port`'s return type.
@tmccombs Are you pursuing this? If not, I might be interested in resurrecting your patch. |
tbh, I'm not entirely sure what to do with this, since I missed the last major release and this is a backwards incompatible change. |
@tmccombs I have an idea for a way to make this happen that wouldn't involve a breaking change, I'll take a crack at it based on your PR. |
As I understand it, this change would be semver-incompatible. I've opened a tracking issue in #627 for proposed semver-incompatible changes to discuss how these could be handled going forward. |
This is also an issue when using the |
Maybe there are some updates on this issue? Or some help is needed to fix it? |
There are a number of methods in url that return
Result<_, ()>
.()
though does not implementError
and so does not inter operate cleanly with callers that want to treat the result asError
(like error-chain).In today's Rust the best pattern for this is probably to create a single
Error
enum for the entire crate to share and return it everywhere.Would require a major version bump.
The text was updated successfully, but these errors were encountered: