use crate::PdbFilenameErrorKind;
use std::error::Error;
use std::fmt;
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum ConfigError {
InvalidPdbFilename {
filename: String,
reason: PdbFilenameErrorKind,
},
EmptyImageKey,
EmptyLocalPdbPath,
EmptyCachePath,
DuplicateImageKey {
key: String,
},
InvalidSymbolServer {
url: String,
reason: SymbolServerErrorKind,
},
EmptySourceRoot,
InvalidCfgName {
name: String,
},
}
impl fmt::Display for ConfigError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidPdbFilename { filename, reason } => {
write!(
formatter,
"invalid logical PDB filename {filename:?}: {reason}"
)
}
Self::EmptyImageKey => formatter.write_str("image key must not be empty"),
Self::EmptyLocalPdbPath => formatter.write_str("local PDB path must not be empty"),
Self::EmptyCachePath => formatter.write_str("cache directory must not be empty"),
Self::DuplicateImageKey { key } => write!(formatter, "duplicate image key {key:?}"),
Self::InvalidSymbolServer { url, reason } => {
write!(formatter, "invalid Symbol Server URL {url:?}: {reason}")
}
Self::EmptySourceRoot => formatter.write_str("source root path must not be empty"),
Self::InvalidCfgName { name } => write!(
formatter,
"invalid cfg name {name:?}: expected one Rust cfg identifier"
),
}
}
}
impl Error for ConfigError {}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum SymbolServerErrorKind {
Scheme,
MissingAuthority,
InvalidCharacter,
}
impl fmt::Display for SymbolServerErrorKind {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(match self {
Self::Scheme => "expected an http:// or https:// URL",
Self::MissingAuthority => "server authority must not be empty",
Self::InvalidCharacter => {
"ASCII whitespace, control characters, queries, and fragments are not allowed"
}
})
}
}