-
Notifications
You must be signed in to change notification settings - Fork 346
Replace () error types in several functions. #515
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
Open
tmccombs
wants to merge
3
commits into
servo:main
Choose a base branch
from
tmccombs:err-enum
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
☔ The latest upstream changes (presumably #517) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
I'm not sure if the errors are appropriate enough
@tmccombs seems like you forgot to update windows specific function: |
Remaining fixes: diff --git a/src/lib.rs b/src/lib.rs
index f87fb02..6690e82 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2408,7 +2408,7 @@ fn file_url_segments_to_pathbuf(
fn file_url_segments_to_pathbuf(
host: Option<&str>,
segments: str::Split<char>,
-) -> Result<PathBuf, ()> {
+) -> Result<PathBuf, ParseError> {
file_url_segments_to_pathbuf_windows(host, segments)
}
@@ -2417,16 +2417,16 @@ fn file_url_segments_to_pathbuf(
fn file_url_segments_to_pathbuf_windows(
host: Option<&str>,
mut segments: str::Split<char>,
-) -> Result<PathBuf, ()> {
+) -> Result<PathBuf, ParseError> {
let mut string = if let Some(host) = host {
r"\\".to_owned() + host
} else {
- let first = segments.next().ok_or(())?;
+ let first = segments.next().ok_or(ParseError::InvalidLocalPath)?;
match first.len() {
2 => {
if !first.starts_with(parser::ascii_alpha) || first.as_bytes()[1] != b':' {
- return Err(());
+ return Err(ParseError::InvalidLocalPath);
}
first.to_owned()
@@ -2434,17 +2434,17 @@ fn file_url_segments_to_pathbuf_windows(
4 => {
if !first.starts_with(parser::ascii_alpha) {
- return Err(());
+ return Err(ParseError::InvalidLocalPath);
}
let bytes = first.as_bytes();
if bytes[1] != b'%' || bytes[2] != b'3' || (bytes[3] != b'a' && bytes[3] != b'A') {
- return Err(());
+ return Err(ParseError::InvalidLocalPath);
}
first[0..1].to_owned() + ":"
}
- _ => return Err(()),
+ _ => return Err(ParseError::InvalidLocalPath),
}
};
@@ -2454,7 +2454,7 @@ fn file_url_segments_to_pathbuf_windows(
// Currently non-unicode windows paths cannot be represented
match String::from_utf8(percent_decode(segment.as_bytes()).collect()) {
Ok(s) => string.push_str(&s),
- Err(..) => return Err(()),
+ Err(..) => return Err(ParseError::InvalidLocalPath),
}
}
let path = PathBuf::from(string); |
Changing the title to note that these changes are semver-incompatible (in my understanding). Tracking all proposed semver-incompatible changes in #627. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an initial pass at #299.
It does not change
ParseError
to the more idiomaticError
name, orchange
with_default_port
's return type.I'm also not 100% sure that the errors I returned are correct.
This change is