soon_migrate/
errors.rs

1use thiserror::Error;
2
3/// Represents all possible errors that can occur during migration.
4#[derive(Error, Debug)]
5pub enum MigrationError {
6    /// Failed to create a backup of the Anchor.toml file.
7    ///
8    /// This typically occurs when there are permission issues or the file is locked.
9    #[error("Failed to backup Anchor.toml: {0}")]
10    BackupFailed(String),
11
12    /// Failed to read the Anchor.toml file.
13    ///
14    /// This can happen if the file doesn't exist or is not accessible.
15    #[error("Failed to read Anchor.toml: {0}")]
16    ReadFailed(String),
17
18    /// Failed to parse the Anchor.toml file.
19    ///
20    /// This indicates the file exists but contains invalid TOML.
21    #[error("Failed to parse Anchor.toml: {0}")]
22    TomlParseError(String),
23
24    /// Failed to write to the Anchor.toml file.
25    ///
26    /// This can occur due to permission issues or disk space problems.
27    #[error("Failed to write Anchor.toml: {0}")]
28    WriteFailed(String),
29
30    /// The specified backup file was not found.
31    ///
32    /// This occurs when trying to restore from a non-existent backup.
33    #[error("Backup file not found at path: {0}")]
34    BackupNotFound(String),
35
36    /// Failed to restore from a backup.
37    ///
38    /// This can happen if the backup file is corrupted or inaccessible.
39    #[error("Failed to restore from backup: {0}")]
40    RestoreFailed(String),
41
42    /// The specified path is not a valid Anchor project.
43    ///
44    /// This error is returned when the expected Anchor project structure is not found.
45    #[error("The specified path is not a valid Anchor project: {0}")]
46    NotAnAnchorProject(String),
47
48    /// Oracle detection failed.
49    ///
50    /// This error occurs when there are issues detecting or analyzing oracles.
51    #[error("Oracle detection failed: {0}")]
52    OracleDetectionFailed(String),
53}