mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-25 19:25:56 +00:00
Phase 3: config engine (line-preserving parser, schemas, validation, atomic save, snapshots, merge, presets) and Bots/Server settings UI
Verified: 28 real config files round-trip byte-identical; native UI edit changes exactly one line in template and generated conf; snapshot restore is byte-exact. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
19024a3162
commit
5b5255cca8
18 files changed
+3668
-3
No files matched your search
@@ -20,6 +20,15 @@ pub enum Error {
|
||||
UnknownInstallation(String),
|
||||
#[error("{0}")]
|
||||
Invalid(String),
|
||||
#[error("invalid values: {}", .0.iter().map(|f| format!("{}: {}", f.key, f.message)).collect::<Vec<_>>().join("; "))]
|
||||
Validation(Vec<FieldError>),
|
||||
}
|
||||
|
||||
/// A problem with one setting, addressed by key so the UI can highlight the field.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct FieldError {
|
||||
pub key: String,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
/// Stable identifiers the UI maps to human messages. Raw exit codes never reach the user.
|
||||
@@ -129,6 +138,7 @@ impl Error {
|
||||
Error::InsufficientSpace { .. } => ErrorCode::DiskFull,
|
||||
Error::HashMismatch { .. } => ErrorCode::HashMismatch,
|
||||
Error::PathRejected(_) => ErrorCode::PathRejected,
|
||||
Error::Validation(_) => ErrorCode::InvalidConfigValue,
|
||||
_ => ErrorCode::Unknown,
|
||||
}
|
||||
}
|
||||
@@ -139,10 +149,15 @@ impl Error {
|
||||
pub struct UiError {
|
||||
pub human: Human,
|
||||
pub technical: String,
|
||||
pub fields: Vec<FieldError>,
|
||||
}
|
||||
|
||||
impl From<Error> for UiError {
|
||||
fn from(e: Error) -> Self {
|
||||
UiError { human: e.code().human(), technical: e.to_string() }
|
||||
let fields = match &e {
|
||||
Error::Validation(f) => f.clone(),
|
||||
_ => Vec::new(),
|
||||
};
|
||||
UiError { human: e.code().human(), technical: e.to_string(), fields }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user