(error: &sqlx::Error)
| 514 | } |
| 515 | |
| 516 | fn 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 | |
| 529 | fn infer_sqlite_unique_constraint(message: &str) -> Option<String> { |
| 530 | if message.contains("objects.object_type, objects.scope, objects.version") { |
no test coverage detected