Files
marqdo/src/host/result.rs
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00

41 lines
1.6 KiB
Rust
Executable File

//! A recoverable failure is data; permission errors remain explicit failures.
use crate::value::Value;
pub(super) fn capture(operation: &str, result: Result<Value, String>) -> Value {
let (ok, value, error) = match result {
Ok(value) => (true, value, Value::None),
Err(message) => {
let tagged = message.split_once(':').map(|(code, _)| code);
let code = match tagged {
Some(
code @ ("validation_failed" | "timed_out" | "permission_denied" | "not_found"
| "conflict" | "invalid_encoding" | "invalid_json" | "invalid_csv"
| "invalid_toml" | "transport_error" | "http_status" | "resource_limit"
| "unsupported" | "invalid_argument" | "nonexistent_time"
| "ambiguous_time"),
) => code,
_ if message.starts_with("path escapes sandbox root:")
|| message.ends_with("denied by host policy") =>
{
"permission_denied"
}
_ => "operation_failed",
};
(
false,
Value::None,
Value::Map(vec![
("code".into(), Value::Text(code.into())),
("message".into(), Value::Text(message)),
("operation".into(), Value::Text(operation.into())),
]),
)
}
};
Value::Map(vec![
("ok".into(), Value::Bool(ok)),
("value".into(), value),
("error".into(), error),
])
}