Rust Util Collection, a simple and friendly error-chain

Overview

GitHub top language Latest Version Rust Documentation GitHub Workflow Status Minimum rustc version

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.

[features]
default = ["ansi"]
ansi = []
compact = []

rich = ["uau", "cmd"]
uau = ["nix", "rand"]
cmd = []

Documents

make doc

Usage

Tips: you can easily implement your own Error type.

Result<()> { l1().c(d!()) }; let l3 = || -> Result<()> { l2().c(d!("A custom message!")) }; let l4 = || -> Result<()> { l3().c(d!("ERR_UNKNOWN")) }; let l5 = || -> Result<()> { l4().c(d!(@CustomErr(-1))) }; pnk!(l5()); }">
use ruc::{err::*, *};

#[derive(Debug, Eq, PartialEq)]
struct CustomErr(i32);

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

    pnk!(l5());
}

OutPut Sample

Non-Color View

features = ["ansi"]

# 2021-09-09 9:23:56 [pid: 20837] [pidns: 4026531836]
ERROR: ...
|-- file: src/lib.rs
|-- line: 270
`-- column: 9
Caused By: ...
|-- file: src/lib.rs
|-- line: 264
`-- column: 16
    Caused By: CustomErr(-1)
    |-- file: src/lib.rs
    |-- line: 262
    `-- column: 44
        Caused By: ERR_UNKNOWN
        |-- file: src/lib.rs
        |-- line: 261
        `-- column: 44
            Caused By: A custom message!
            |-- file: src/lib.rs
            |-- line: 260
            `-- column: 44
                Caused By: ...
                |-- file: src/lib.rs
                |-- line: 259
                `-- column: 69
                    Caused By: The final error message!
                    |-- file: src/lib.rs
                    |-- line: 258
                    `-- column: 41

Colorful View

# 2021-09-09 9:23:57 [pid: 20909] [pidns: 4026531836]
ERROR: ...
├── file: src/lib.rs
├── line: 270
└── column: 9
Caused By: ...
├── file: src/lib.rs
├── line: 264
└── column: 16
    Caused By: CustomErr(-1)
    ├── file: src/lib.rs
    ├── line: 262
    └── column: 44
        Caused By: ERR_UNKNOWN
        ├── file: src/lib.rs
        ├── line: 261
        └── column: 44
            Caused By: A custom message!
            ├── file: src/lib.rs
            ├── line: 260
            └── column: 44
                Caused By: ...
                ├── file: src/lib.rs
                ├── line: 259
                └── column: 69
                    Caused By: The final error message!
                    ├── file: src/lib.rs
                    ├── line: 258
                    └── column: 41

Compact View

features = ["compact"]

# 2022-01-12 5:56:13 [pid: 73002] [pidns: NULL] 》INFO: ... 》file: src/lib.rs 》line: 354 》column: 9 》Caused By: ... 》file: src/lib.rs 》line: 354 》column: 33
You might also like...
Minimal, flexible & user-friendly X and Wayland tiling window manager with rust
Minimal, flexible & user-friendly X and Wayland tiling window manager with rust

SSWM Minimal, flexible & user-friendly X and Wayland tiling window manager but with rust. Feel free to open issues and make pull requests. [Overview]

supply-chain security for Rust

cargo-vet Note: cargo-vet is under heavy development and not quite ready for general use. Feel free to give it a try you're feeling adventerous — feed

A super super super voting system on near block chain :)

Disp41r-Super-Voting-System a super super super voting system on near block chain :) Finish! I call it super voting system, because it is really cool!

A strict, yet friendly mocking library for Rust 2018

Mockiato A strict, yet friendly mocking library for Rust 2018 ⚠️ Disclaimer for working with stable rust Mockiato relies on the unstable proc_macro_di

🐦 Friendly little instrumentation profiler for Rust 🦀
🐦 Friendly little instrumentation profiler for Rust 🦀

🐦 puffin The friendly little instrumentation profiler for Rust How to use fn my_function() { puffin::profile_function!(); ... if ... {

Byte is a blazingly fast🚀 Discord Bot with a user-friendly design using twilight written in rust🦀.

Byte Byte is a blazingly fast🚀 Discord Bot with a user-friendly design using twilight written in rust🦀. How To Run There is a public version of the

dbt Cloud™️ infrastructure-as-code that is friendly to analysts
dbt Cloud™️ infrastructure-as-code that is friendly to analysts

dbterra dbt Cloud ™️ infrastructure-as-code that is friendly to analysts, bizops, etc Motivation While there are Terraform ™️ plugins that can be used

mollusc is a collection of pure-Rust libraries for parsing, interpreting, and analyzing LLVM.

mollusc is a collection of pure-Rust libraries for parsing, interpreting, and analyzing LLVM.

A command-line tool collection to assist development written in RUST

dtool dtool is a command-line tool collection to assist development Table of Contents Description Usage Tips Installation Description Now dtool suppor

Owner
凡日月所照,江河所至,皆為漢土。
漢
miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

Kat Marchán 1.2k Jan 1, 2023
PM-Tools - a simple Rust util to easily create server directories

PM-Tools PM-Tools is a simple Rust util to easily create server directories or plugins without the hassle of unzipping or creating directories Progres

null 2 Mar 19, 2022
A mostly drop-in replacement for mercantile written w/ rust, plus several other util(e)ities.

utiles utiles = utils + tiles A mostly drop-in replacement for mercantile written w/ rust, plus several other util(e)ities. Installation pip install u

jesse 5 Jun 20, 2023
Graceful shutdown util for Rust projects using the Tokio Async runtime.

Shutdown management for graceful shutdown of tokio applications. Guard creating and usage is lock-free and the crate only locks when: the shutdown sig

Plabayo 54 Sep 29, 2023
Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust

Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust, and with an eye towards serializing runtime errors using serde.

Findora Foundation 1 Feb 12, 2022
my attempt at compromise between unwrapping and bullying my dependencies' authors for Error impl

string-eyre Has this happened to you? error[E0599]: the method `wrap_err` exists for enum `Result<(), tauri::Error>`, but its trait bounds were not sa

Michał Sidor 1 Nov 25, 2021
Error propagation tracing in Rust.

Propagate Error propagation tracing in Rust. Why Propagate? Being able to trace the cause of an error is critical for many types of software written i

Ben Reeves 10 Sep 23, 2021
A fancy diagnostics & error reporting crate

A fancy diagnostics & error reporting crate

Joshua Barretto 1.1k Dec 30, 2022
Better error messages for axum framework.

axum-debug This is a debugging crate that provides better error messages for axum framework. axum is a great framework for developing web applications

Eray Karatay 3 Feb 3, 2022
Watches changes in a rust project, runs test and shows friendly notification

Cargo testify Automatically runs tests on your Rust project and notifies about the result. Install Install prerequisites (for Debian/Ubuntu): apt-get

Sergey Potapov 77 May 16, 2022