1 个不稳定版本
0.0.1 | 2023年5月14日 |
---|
#18 在 #json-error
18KB
280 行
README
printjsonerr 帮助打印 JSON 错误
用法
use jsonerr::*;
use printjsonerr::*;
fn main() {
let myjsonerr: serde_json::Value = jsonerr!(code = "ERR001", message = "An error message");
printjsonerr!(myjsonerr); // without & (added internaly)
printjsonerr!(&myjsonerr); // with &
}
┌----------------------------
| meta: errjson/examples/full.rs, line=45, function=main()
| ERR0001: Error when main() call myfnc()
| origin:
| ┌----------------------------
| | meta: errjson/examples/full.rs, line=29, function=myfnc()
| | ERR0002: Error when myfnc() call mysubfnc()
| | origin:
| | ┌----------------------------
| | | meta: errjson/examples/full.rs, line=12, function=mysubfnc()
| | | ERR003: Error when mysubfnc() call mysubsubfnc()
| | | origin:
| | | ┌----------------------------
| | | | std:error:Error: No such file or directory (os error 2)
示例
cargorun --examplebasic
依赖
~0.7–1.5MB
~33K SLoC