errjson 0.0.2

Easy complex and intuitive Rust Error json
Documentation
# README

[ErrJson](https://crates.io/crates/errjson): easy complex and intuitive Rust [Error](https://doc.rust-lang.org/std/error/trait.Error.html) json

## Usage

```rust
use errjson::*;
fn myfnc() -> Result<i32, Box<dyn std::error::Error>> {
    ErrJson!(code = "ERR001", message = "An error message")
}
```

return a valid Rust [Error](https://doc.rust-lang.org/std/error/trait.Error.html) with a json stringify

```json
{
    "iserr":true,
    "err":{
        "code":"ERR001",
        "message":"An error message"
    }
}
```

You can also embed cascading errors and get a json that looks like this ([full example code](./examples/full.rs))

```json
{
    "meta": { "whoami": { "filename": "errjson/examples/full.rs", "function": "main", "line": 42 } },
    "iserr": true,
    "err": {
        "code": "ERR0001",
        "message": "Error when main() call myfnc()",
        "origin": {
            "meta": { "whoami": { "filename": "errjson/examples/full.rs", "function": "myfnc", "line": 26 } },
            "iserr": true,
            "err": {
                "code": "ERR0002",
                "message": "Error when myfnc() call mysubfnc()",
                "origin": {
                    "meta": { "whoami": { "filename": "errjson/examples/full.rs", "function": "mysubfnc", "line": 11 } },
                    "iserr": true,
                    "err": {
                        "code": "ERR003",
                        "message": "Error when mysubfnc() call mysubsubfnc()",
                        "origin": "No such file or directory (os error 2)"
                    },
                }
            },
        }
    },
}
```

## Examples

- `cargo run --example full`
- `cargo run --example minimal`

##  Why ErrJson ?

Without [ErrJson](https://crates.io/crates/errjson), you can can write basic `Err` like this, but hard with a complex json, not normalize and difficult to embed 'caused' error.

- `Err(r#"{"error":"json", ...}"#);`
- `Err(serde_json::to_string(serde_json::json!({"error": "json", ...})));`