api: add structured context for usage and session errors
This commit is contained in:
@@ -1439,10 +1439,13 @@ impl AdminService {
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
ApiError::not_found(format!(
|
||||
"usage for operation {} was not found",
|
||||
operation_id.as_str()
|
||||
))
|
||||
ApiError::not_found_with_context(
|
||||
format!(
|
||||
"usage for operation {} was not found",
|
||||
operation_id.as_str()
|
||||
),
|
||||
json!({ "operation_id": operation_id.as_str() }),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1470,10 +1473,10 @@ impl AdminService {
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
ApiError::not_found(format!(
|
||||
"usage for agent {} was not found",
|
||||
agent_id.as_str()
|
||||
))
|
||||
ApiError::not_found_with_context(
|
||||
format!("usage for agent {} was not found", agent_id.as_str()),
|
||||
json!({ "agent_id": agent_id.as_str() }),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1534,10 +1537,10 @@ impl AdminService {
|
||||
.get_stream_session(session_id)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
ApiError::not_found(format!(
|
||||
"stream session {} was not found",
|
||||
session_id.as_str()
|
||||
))
|
||||
ApiError::not_found_with_context(
|
||||
format!("stream session {} was not found", session_id.as_str()),
|
||||
json!({ "session_id": session_id.as_str() }),
|
||||
)
|
||||
})?;
|
||||
ensure_stream_session_workspace(&session, workspace_id)?;
|
||||
|
||||
@@ -1556,10 +1559,10 @@ impl AdminService {
|
||||
.get_stream_session(session_id)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
ApiError::not_found(format!(
|
||||
"stream session {} was not found",
|
||||
session_id.as_str()
|
||||
))
|
||||
ApiError::not_found_with_context(
|
||||
format!("stream session {} was not found", session_id.as_str()),
|
||||
json!({ "session_id": session_id.as_str() }),
|
||||
)
|
||||
})?;
|
||||
ensure_stream_session_workspace(&session, workspace_id)?;
|
||||
self.registry
|
||||
@@ -1570,10 +1573,10 @@ impl AdminService {
|
||||
.get_stream_session(session_id)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
ApiError::not_found(format!(
|
||||
"stream session {} was not found",
|
||||
session_id.as_str()
|
||||
))
|
||||
ApiError::not_found_with_context(
|
||||
format!("stream session {} was not found", session_id.as_str()),
|
||||
json!({ "session_id": session_id.as_str() }),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(stream_session_detail_view(updated))
|
||||
|
||||
Reference in New Issue
Block a user