#error #error-logging #logging #error-handle

log-error

A small crate to log the error result easily

2 releases

0.1.1 Mar 6, 2023
0.1.0 Jun 23, 2022

#31 in #error-logging

Download history 69/week @ 2024-03-11 14/week @ 2024-03-18 23/week @ 2024-03-25 82/week @ 2024-04-01 19/week @ 2024-04-08 63/week @ 2024-04-15 16/week @ 2024-04-22 14/week @ 2024-04-29 15/week @ 2024-05-06 9/week @ 2024-05-13 20/week @ 2024-05-20 12/week @ 2024-05-27 9/week @ 2024-06-03 10/week @ 2024-06-10 57/week @ 2024-06-17 17/week @ 2024-06-24

94 downloads per month
Used in 2 crates

MIT license

6KB
92 lines

log-error

A small crate to log the error result easily

Sometimes we just want to record the error result, rather than return it to upper caller or unwrap the result with a panic, this crate will help you do it in relaxed

Example

use log_error::*;
use std::io::Error;

fn main() {
    simple_logger::SimpleLogger::new().env().init().unwrap();

    if let Some(_file) = std::fs::read("").log_warn("optional file") {
        // do something
    }

    // detailed error message
    do_something().log_error_detail("do_something");
}

fn do_something() -> Result<(), Error> {
    // ...
    Err(Error::last_os_error())
}

Dependencies

~88KB