fix: replace matches with pattern matching for CoreError handling
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -197,8 +197,9 @@ pub async fn handle_get_item_latest_content(
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Check if the error is ItemNotFoundGeneric to return 404
|
// Check if the error is ItemNotFoundGeneric to return 404
|
||||||
if let Some(core_err) = e.downcast_ref::<CoreError>() {
|
if let Some(core_err) = e.downcast_ref::<CoreError>() {
|
||||||
if matches!(core_err, CoreError::ItemNotFoundGeneric) {
|
match core_err {
|
||||||
return Err(StatusCode::NOT_FOUND);
|
CoreError::ItemNotFoundGeneric => return Err(StatusCode::NOT_FOUND),
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
warn!("Failed to find latest item for content: {}", e);
|
warn!("Failed to find latest item for content: {}", e);
|
||||||
@@ -258,8 +259,9 @@ pub async fn handle_get_item_content(
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Check if the error is ItemNotFound to return 404
|
// Check if the error is ItemNotFound to return 404
|
||||||
if let Some(core_err) = e.downcast_ref::<CoreError>() {
|
if let Some(core_err) = e.downcast_ref::<CoreError>() {
|
||||||
if matches!(core_err, CoreError::ItemNotFound(_)) {
|
match core_err {
|
||||||
return Err(StatusCode::NOT_FOUND);
|
CoreError::ItemNotFound(_) => return Err(StatusCode::NOT_FOUND),
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
warn!("Failed to get raw content for item {}: {}", item_id, e);
|
warn!("Failed to get raw content for item {}: {}", item_id, e);
|
||||||
|
|||||||
Reference in New Issue
Block a user