Improved error handling (part 1)
This commit is contained in:
@@ -5,6 +5,7 @@ edition = "2021"
|
||||
resolver = "2"
|
||||
|
||||
[dependencies]
|
||||
trc = { path = "../trc" }
|
||||
rustls = { version = "0.23.5", default-features = false, features = ["std", "ring", "tls12"] }
|
||||
rustls-pemfile = "2.0"
|
||||
rustls-pki-types = { version = "1" }
|
||||
|
||||
@@ -32,6 +32,7 @@ pub enum ConfigWarning {
|
||||
AppliedDefault { default: String },
|
||||
Unread { value: String },
|
||||
Build { error: String },
|
||||
Parse { error: String },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
@@ -54,7 +55,7 @@ pub struct Rate {
|
||||
pub period: Duration,
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, String>;
|
||||
pub(crate) type Result<T> = std::result::Result<T, String>;
|
||||
|
||||
impl Config {
|
||||
pub async fn resolve_macros(&mut self, classes: &[&str]) {
|
||||
@@ -206,6 +207,9 @@ impl Config {
|
||||
ConfigWarning::Unread { value } => {
|
||||
format!("WARNING: Unused setting {key:?} with value {value:?}")
|
||||
}
|
||||
ConfigWarning::Parse { error } => {
|
||||
format!("WARNING: Failed to parse {key:?}: {error}")
|
||||
}
|
||||
ConfigWarning::Build { error } => format!("WARNING for {key:?}: {error}"),
|
||||
};
|
||||
if !use_stderr {
|
||||
|
||||
@@ -294,6 +294,15 @@ impl Config {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn new_parse_warning(&mut self, key: impl AsKey, details: impl Into<String>) {
|
||||
self.warnings.insert(
|
||||
key.as_key(),
|
||||
ConfigWarning::Parse {
|
||||
error: details.into(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
pub fn new_build_warning(&mut self, key: impl AsKey, details: impl Into<String>) {
|
||||
self.warnings.insert(
|
||||
key.as_key(),
|
||||
|
||||
Reference in New Issue
Block a user