Skip to content

Commit 5f81817

Browse files
committed
Use let_chain instead of nested if conditions
1 parent 5b75617 commit 5f81817

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/web/releases.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,13 @@ async fn get_search_results(
256256
// Categorize errors from registry
257257
fn handle_registry_error(err: anyhow::Error) -> Result<SearchResult, SearchError> {
258258
// Capture crates.io API error
259-
if let Some(registry_request_error) = err.downcast_ref::<reqwest::Error>() {
260-
if let Some(status) = registry_request_error.status() {
261-
if status.is_client_error() || status.is_server_error() {
262-
return Err(SearchError::CratesIo(format!(
263-
"crates.io returned {status}: {registry_request_error}"
264-
)));
265-
}
266-
}
259+
if let Some(registry_request_error) = err.downcast_ref::<reqwest::Error>()
260+
&& let Some(status) = registry_request_error.status()
261+
&& (status.is_client_error() || status.is_server_error())
262+
{
263+
return Err(SearchError::CratesIo(format!(
264+
"crates.io returned {status}: {registry_request_error}"
265+
)));
267266
}
268267
// Move all other error types to this wrapper
269268
Err(SearchError::Other(err))

0 commit comments

Comments
 (0)