Skip to main content

dnx_core/
errors.rs

1use thiserror::Error;
2
3/// Main error type for Dnx operations
4#[derive(Error, Debug)]
5pub enum DnxError {
6    /// Network-related errors
7    #[error("Network error: {0}")]
8    Network(String),
9
10    /// Registry-related errors
11    #[error("Registry error: {0}")]
12    Registry(String),
13
14    /// Dependency resolution errors
15    #[error("Resolution error: {0}")]
16    Resolution(String),
17
18    /// Package integrity errors
19    #[error("Integrity error: {0}")]
20    Integrity(String),
21
22    /// Invalid integrity hash format
23    #[error("Invalid integrity: {0}")]
24    InvalidIntegrity(String),
25
26    /// I/O errors (string message)
27    #[error("I/O error: {0}")]
28    Io(String),
29
30    /// Std I/O errors (auto-converted)
31    #[error("I/O error: {0}")]
32    StdIo(#[from] std::io::Error),
33
34    /// JSON parsing errors (auto-converted)
35    #[error("JSON error: {0}")]
36    Json(#[from] serde_json::Error),
37
38    /// Parse errors
39    #[error("Parse error: {0}")]
40    ParseError(String),
41
42    /// TOML parsing errors
43    #[error("TOML error: {0}")]
44    Toml(String),
45
46    /// Cache-related errors
47    #[error("Cache error: {0}")]
48    Cache(String),
49
50    /// Linker-related errors
51    #[error("Linker error: {0}")]
52    Linker(String),
53
54    /// Lockfile-related errors
55    #[error("Lockfile error: {0}")]
56    Lockfile(String),
57
58    /// Package not found error
59    #[error("Package not found: {0}")]
60    PackageNotFound(String),
61
62    /// Version not found error
63    #[error("Version {version} not found for package {package}")]
64    VersionNotFound { package: String, version: String },
65
66    /// Configuration errors
67    #[error("Configuration error: {0}")]
68    Config(String),
69
70    /// Workspace-related errors
71    #[error("Workspace error: {0}")]
72    Workspace(String),
73
74    /// Catalog-related errors
75    #[error("Catalog error: {0}")]
76    Catalog(String),
77
78    /// Patch-related errors
79    #[error("Patch error: {0}")]
80    Patch(String),
81
82    /// Publish-related errors
83    #[error("Publish error: {0}")]
84    Publish(String),
85
86    /// Hook-related errors (.pnpmfile.cjs)
87    #[error("Hook error: {0}")]
88    Hook(String),
89
90    /// Another dnx process is already running
91    #[error("Process lock error: {0}")]
92    ProcessLock(String),
93}
94
95/// Result type alias for Dnx operations
96pub type Result<T> = std::result::Result<T, DnxError>;