printjsonerr

Crates.ioprintjsonerr
lib.rsprintjsonerr
version0.0.1
sourcesrc
created_at2023-05-14 20:10:33.062671
updated_at2023-05-14 20:10:33.062671
descriptionprint json err
homepage
repositoryhttps://codeberg.org/AlbanMinassian/errorjson
max_upload_size
id864458
size22,047
Alban Minassian (AlbanMinassian)

documentation

https://docs.rs/jsonerr

README

README

crates.io docs.rs github

printjsonerr help to print json error

Usage

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 &
}

print

┌----------------------------
| 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)

Examples

  • cargo run --example basic
Commit count: 0

cargo fmt