| 366 | |
| 367 | impl fmt::Display for PristineError { |
| 368 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 369 | match self { |
| 370 | // Database errors |
| 371 | Self::Database(e) => write!(f, "database error: {}", e), |
| 372 | Self::Transaction(e) => write!(f, "transaction error: {}", e), |
| 373 | Self::Table(e) => write!(f, "table error: {}", e), |
| 374 | Self::Storage(e) => write!(f, "storage error: {}", e), |
| 375 | Self::Commit(e) => write!(f, "commit error: {}", e), |
| 376 | |
| 377 | // I/O errors |
| 378 | Self::Io(e) => write!(f, "IO error: {}", e), |
| 379 | |
| 380 | // Not found errors |
| 381 | Self::ViewNotFound { name } => write!(f, "view not found: {}", name), |
| 382 | Self::ViewAlreadyExists { name } => { |
| 383 | write!(f, "view already exists: {}", name) |
| 384 | } |
| 385 | Self::CannotDeleteSharedView { name } => { |
| 386 | write!( |
| 387 | f, |
| 388 | "cannot delete shared view '{}': shared views are permanent", |
| 389 | name |
| 390 | ) |
| 391 | } |
| 392 | Self::ViewHasChildren { name, children } => { |
| 393 | write!( |
| 394 | f, |
| 395 | "cannot delete view '{}': has child views: {}", |
| 396 | name, |
| 397 | children.join(", ") |
| 398 | ) |
| 399 | } |
| 400 | Self::ViewCycleDetected { name, parent_name } => { |
| 401 | write!( |
| 402 | f, |
| 403 | "cannot set parent of '{}' to '{}': would create a cycle", |
| 404 | name, parent_name |
| 405 | ) |
| 406 | } |
| 407 | Self::BrokenViewParent { |
| 408 | view_id, |
| 409 | view_name, |
| 410 | parent_id, |
| 411 | } => write!( |
| 412 | f, |
| 413 | "view '{}' ({}) references missing parent view {}; repair the view hierarchy before resolving visibility", |
| 414 | view_name, view_id, parent_id |
| 415 | ), |
| 416 | Self::WorkingCopySchemaUnavailable => write!( |
| 417 | f, |
| 418 | "working-copy storage is unavailable; reopen the repository normally with write access to initialize the WORKING_COPIES table" |
| 419 | ), |
| 420 | Self::OperationSchemaUnavailable => write!( |
| 421 | f, |
| 422 | "operation-journal storage is unavailable; reopen the repository normally with write access to initialize OPERATIONS, OP_HEADS, and EFFECT_RECEIPTS" |
| 423 | ), |
| 424 | Self::OperationNotFound { id } => { |
| 425 | write!(f, "operation not found: {id}") |