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

Function map_db_error

crates/openshell-server/src/persistence/mod.rs:516–527  ·  view source on GitHub ↗
(error: &sqlx::Error)

Source from the content-addressed store, hash-verified

514}
515
516fn map_db_error(error: &sqlx::Error) -> PersistenceError {
517 if let sqlx::Error::Database(db) = error
518 && db.is_unique_violation()
519 {
520 let constraint = db
521 .constraint()
522 .map(ToString::to_string)
523 .or_else(|| infer_sqlite_unique_constraint(db.message()));
524 return PersistenceError::unique_violation(constraint, Some(db.message().to_string()));
525 }
526 PersistenceError::Database(error.to_string())
527}
528
529fn infer_sqlite_unique_constraint(message: &str) -> Option<String> {
530 if message.contains("objects.object_type, objects.scope, objects.version") {

Callers 15

connectMethod · 0.85
pingMethod · 0.85
putMethod · 0.85
put_ifMethod · 0.85
delete_ifMethod · 0.85
put_scopedMethod · 0.85
getMethod · 0.85
get_by_nameMethod · 0.85
deleteMethod · 0.85
delete_by_nameMethod · 0.85
listMethod · 0.85
list_by_scopeMethod · 0.85

Calls 2

messageMethod · 0.80

Tested by

no test coverage detected