MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / persistence_error_to_status

Function persistence_error_to_status

crates/openshell-server/src/grpc/mod.rs:80–96  ·  view source on GitHub ↗

Map a `PersistenceError` to an appropriate gRPC `Status`. CAS conflicts (optimistic concurrency failures) are mapped to `ABORTED` to signal that the client should retry with fresh data. Other persistence errors are mapped to `INTERNAL`.

(
    err: crate::persistence::PersistenceError,
    operation: &str,
)

Source from the content-addressed store, hash-verified

78/// to signal that the client should retry with fresh data. Other persistence
79/// errors are mapped to `INTERNAL`.
80pub fn persistence_error_to_status(
81 err: crate::persistence::PersistenceError,
82 operation: &str,
83) -> Status {
84 use crate::persistence::PersistenceError;
85
86 match err {
87 PersistenceError::Conflict {
88 current_resource_version,
89 } => Status::aborted(format!(
90 "{} failed due to concurrent modification (current resource_version: {})",
91 operation,
92 current_resource_version.map_or_else(|| "unknown".to_string(), |v| v.to_string())
93 )),
94 other => Status::internal(format!("{operation} failed: {other}")),
95 }
96}
97
98// ---------------------------------------------------------------------------
99// Field-level size limits (shared across submodules)

Calls

no outgoing calls

Tested by

no test coverage detected