pdb_bindgen_codegen/config/
error.rs1use crate::PdbFilenameErrorKind;
2use std::error::Error;
3use std::fmt;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7#[non_exhaustive]
8pub enum ConfigError {
9 InvalidPdbFilename {
11 filename: String,
13 reason: PdbFilenameErrorKind,
15 },
16 EmptyImageKey,
18 EmptyLocalPdbPath,
20 EmptyCachePath,
22 DuplicateImageKey {
24 key: String,
26 },
27 InvalidSymbolServer {
29 url: String,
31 reason: SymbolServerErrorKind,
33 },
34 EmptySourceRoot,
36 InvalidCfgName {
38 name: String,
40 },
41}
42
43impl fmt::Display for ConfigError {
44 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
45 match self {
46 Self::InvalidPdbFilename { filename, reason } => {
47 write!(
48 formatter,
49 "invalid logical PDB filename {filename:?}: {reason}"
50 )
51 }
52 Self::EmptyImageKey => formatter.write_str("image key must not be empty"),
53
54 Self::EmptyLocalPdbPath => formatter.write_str("local PDB path must not be empty"),
55 Self::EmptyCachePath => formatter.write_str("cache directory must not be empty"),
56 Self::DuplicateImageKey { key } => write!(formatter, "duplicate image key {key:?}"),
57 Self::InvalidSymbolServer { url, reason } => {
58 write!(formatter, "invalid Symbol Server URL {url:?}: {reason}")
59 }
60 Self::EmptySourceRoot => formatter.write_str("source root path must not be empty"),
61 Self::InvalidCfgName { name } => write!(
62 formatter,
63 "invalid cfg name {name:?}: expected one Rust cfg identifier"
64 ),
65 }
66 }
67}
68
69impl Error for ConfigError {}
70
71#[derive(Clone, Copy, Debug, Eq, PartialEq)]
73#[non_exhaustive]
74pub enum SymbolServerErrorKind {
75 Scheme,
77 MissingAuthority,
79 InvalidCharacter,
81}
82
83impl fmt::Display for SymbolServerErrorKind {
84 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
85 formatter.write_str(match self {
86 Self::Scheme => "expected an http:// or https:// URL",
87 Self::MissingAuthority => "server authority must not be empty",
88 Self::InvalidCharacter => {
89 "ASCII whitespace, control characters, queries, and fragments are not allowed"
90 }
91 })
92 }
93}