Skip to main content

vs_core/
error.rs

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