Skip to content
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

WASIX: Add QueryError::Timeout #4369

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/wasix/src/runtime/resolver/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ pub enum QueryError {
NoMatches {
archived_versions: Vec<semver::Version>,
},
Timeout,
Other(anyhow::Error),
}

impl From<anyhow::Error> for QueryError {
fn from(value: anyhow::Error) -> Self {
QueryError::Other(value)
Self::Other(value)
}
}

impl Display for QueryError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
QueryError::Unsupported => {
f.write_str("This type of package specifier isn't supported")
}
QueryError::NotFound => f.write_str("Not found"),
QueryError::NoMatches { archived_versions } => match archived_versions.as_slice() {
Self::Unsupported => f.write_str("This type of package specifier isn't supported"),
Self::NotFound => f.write_str("Not found"),
Self::Timeout => f.write_str("Timed out"),
Self::NoMatches { archived_versions } => match archived_versions.as_slice() {
[] => f.write_str(
"The package was found, but no published versions matched the constraint",
),
Expand All @@ -80,16 +80,16 @@ impl Display for QueryError {
)
}
},
QueryError::Other(e) => Display::fmt(e, f),
Self::Other(e) => Display::fmt(e, f),
}
}
}

impl std::error::Error for QueryError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
QueryError::Other(e) => Some(&**e),
QueryError::Unsupported | QueryError::NotFound | QueryError::NoMatches { .. } => None,
Self::Other(e) => Some(&**e),
Self::Unsupported | Self::NotFound | Self::NoMatches { .. } | Self::Timeout => None,
}
}
}
Loading