🏗️ refactor(kebab-config): stabilize ConfigInvalid.cause prefix (fb-27)
Replace `read failed: {e}` / `parse failed: {e}` with the underscore-
slugged `read_failed:` / `parse_failed:` prefixes so kebab-cli's
error_classify (Task 8) and the error.v1 JSON Schema (Task 14) can
treat the prefix as a stable wire contract while leaving the OS /
toml-crate detail in the suffix as free-form context.
Also add the symmetric `cause` non-empty assertion to the malformed-TOML
test so a regression that empties `cause` on the parse path would be
caught.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -409,7 +409,7 @@ impl Config {
|
||||
let text = std::fs::read_to_string(path).map_err(|e| {
|
||||
anyhow::Error::new(ConfigInvalid {
|
||||
path: path.to_path_buf(),
|
||||
cause: format!("read failed: {e}"),
|
||||
cause: format!("read_failed: {e}"),
|
||||
})
|
||||
})?;
|
||||
|
||||
@@ -438,7 +438,7 @@ impl Config {
|
||||
let mut cfg: Self = toml::from_str(&text).map_err(|e| {
|
||||
anyhow::Error::new(ConfigInvalid {
|
||||
path: path.to_path_buf(),
|
||||
cause: format!("parse failed: {e}"),
|
||||
cause: format!("parse_failed: {e}"),
|
||||
})
|
||||
})?;
|
||||
cfg.source_dir = path.parent().map(Path::to_path_buf);
|
||||
@@ -982,5 +982,6 @@ mod fb27_tests {
|
||||
let signal = err.downcast_ref::<ConfigInvalid>()
|
||||
.expect("malformed TOML should downcast to ConfigInvalid");
|
||||
assert_eq!(signal.path, p);
|
||||
assert!(!signal.cause.is_empty(), "cause should be non-empty");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user