1 Star 0 Fork 0

範輝 / myutil

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

RUC

Rust Util Collection, a simple and friendly error-chain, with many useful utils as an addition.

The painful experience of using error-chain gave birth to this project. It can adapt to almost all scenes without any special implementation.

Documents

make doc

Usage

Tips: you can easily implement your own Error type.

use myutil::{err::*, *};

const ERR_UNKNOWN: i32 = -100;

fn will_panic() {
    let l1 = || -> Result<()> { Err(eg!(-9, "The final error message!")) };
    let l2 = || -> Result<()> { l1().c(d!()) };
    let l3 = || -> Result<()> { l2().c(d!(-11, "A custom message!")) };
    let l4 = || -> Result<()> { l3().c(e!(ERR_UNKNOWN)) };
    let l5 = || -> Result<()> { l4().c(d!(@-12)) };

    pnk!(l5());
}

OutPut Sample

nocolor (features = "ansi")

# 2021-01-10 11:23:07 [idx: 0] [pid: 52827] [pidns: NULL]
Error:
|-- eno: -1
|-- file: src/lib.rs
|-- line: 370
`-- column: 9
Caused By:
|-- eno: -12
|-- file: src/lib.rs
|-- line: 368
`-- column: 44
    Caused By: ERR_UNKNOWN
    |-- eno: -100
    |-- file: src/lib.rs
    |-- line: 367
    `-- column: 44
        Caused By: A custom message!
        |-- eno: -11
        |-- file: src/lib.rs
        |-- line: 366
        `-- column: 44
            Caused By:
            |-- eno: -1
            |-- file: src/lib.rs
            |-- line: 365
            `-- column: 44
                Caused By: The final error message!
                |-- eno: -9
                |-- file: src/lib.rs
                |-- line: 364
                `-- column: 41

colorful

# 2021-01-10 11:25:14 [idx: 0] [pid: 52892] [pidns: NULL]
Error:
├── eno: -1
├── file: src/lib.rs
├── line: 370
└── column: 9
Caused By:
├── eno: -12
├── file: src/lib.rs
├── line: 368
└── column: 44
    Caused By: ERR_UNKNOWN
    ├── eno: -100
    ├── file: src/lib.rs
    ├── line: 367
    └── column: 44
        Caused By: A custom message!
        ├── eno: -11
        ├── file: src/lib.rs
        ├── line: 366
        └── column: 44
            Caused By:
            ├── eno: -1
            ├── file: src/lib.rs
            ├── line: 365
            └── column: 44
                Caused By: The final error message!
                ├── eno: -9
                ├── file: src/lib.rs
                ├── line: 364
                └── column: 41
MIT License Copyright (c) 2020 西门-范辉 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

keep old crates compiled. 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/kt10/myutil.git
git@gitee.com:kt10/myutil.git
kt10
myutil
myutil
master

搜索帮助