fix: handle CoreError downcasting properly in error handling

Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-25 18:20:14 -03:00
parent c49a63bb10
commit 6c00c2ab56

View File

@@ -195,6 +195,12 @@ pub async fn handle_get_item_latest_content(
} }
Err(CoreError::ItemNotFoundGeneric) => Err(StatusCode::NOT_FOUND), Err(CoreError::ItemNotFoundGeneric) => Err(StatusCode::NOT_FOUND),
Err(e) => { Err(e) => {
// Check if the error is ItemNotFoundGeneric to return 404
if let Some(core_err) = e.downcast_ref::<CoreError>() {
if matches!(core_err, 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);
Err(StatusCode::INTERNAL_SERVER_ERROR) Err(StatusCode::INTERNAL_SERVER_ERROR)
} }