Skip to main content

vs_core/
error.rs

1//! Error types returned by the core application layer.
2
3use std::path::PathBuf;
4
5use thiserror::Error;
6
7/// Errors returned by the application layer.
8#[derive(Debug, Error)]
9pub enum CoreError {
10    /// A filesystem operation failed.
11    #[error(transparent)]
12    Io(#[from] std::io::Error),
13    /// An HTTP request failed.
14    #[error(transparent)]
15    Http(#[from] reqwest::Error),
16    /// An archive could not be extracted.
17    #[error(transparent)]
18    Archive(#[from] zip::result::ZipError),
19    /// Configuration error.
20    #[error(transparent)]
21    Config(#[from] vs_config::ConfigError),
22    /// Registry error.
23    #[error(transparent)]
24    Registry(#[from] vs_registry::RegistryError),
25    /// Installer error.
26    #[error(transparent)]
27    Installer(#[from] vs_installer::InstallerError),
28    /// Shell error.
29    #[error(transparent)]
30    Shell(#[from] vs_shell::ShellError),
31    /// Plugin error.
32    #[error(transparent)]
33    Plugin(#[from] vs_plugin_api::PluginError),
34    /// A required plugin is not registered.
35    #[error("plugin {0} is not known to the registry or local home")]
36    UnknownPlugin(String),
37    /// A feature is unavailable in this build.
38    #[error("{0}")]
39    Unsupported(String),
40    /// The current command requires a session id.
41    #[error("session scope requires VS_SESSION_ID to be set")]
42    MissingSessionId,
43    /// A requested tool version is not currently active.
44    #[error("tool {0} is not currently active")]
45    InactiveTool(String),
46    /// A command could not parse a registry source file.
47    #[error("failed to parse registry source at {path}: {message}")]
48    RegistrySource { path: PathBuf, message: String },
49    /// An external process failed to execute.
50    #[error("failed to execute command {command}: {message}")]
51    CommandExecution { command: String, message: String },
52    /// A migration source could not be found.
53    #[error("no migration source home is available")]
54    MissingMigrationSource,
55    /// The selected backend is not compiled into this build.
56    #[error(
57        "plugin backend {backend} is not enabled in this build; rebuild with the `{feature}` feature"
58    )]
59    UnsupportedBackend {
60        backend: &'static str,
61        feature: &'static str,
62    },
63}