log_err

Crates.iolog_err
lib.rslog_err
version1.1.1
sourcesrc
created_at2021-04-12 15:47:35.994956
updated_at2021-04-25 10:49:47.911351
descriptionLog error messages from Unwrap and Expect with log crate
homepage
repositoryhttps://github.com/DesmondWillowbrook/rs-log_err
max_upload_size
id382454
size7,600
Kartavya Vashishtha (DesmondWillowbrook)

documentation

README

Crates.io License Docs

Log_Err

A small extension to the log crate, which provides two methods for core::result::Result<T, E> and core::option::Option<T>

log_except and log_unwrap, which invoke the log::error! macro (in case of Result::Err/Option::None) in addition to unwrapping/expecting the Result/Option.

Shorthand for:

something().map_err(|e| error!("{}: {:?}", msg, e)).expect(msg)

Example:

let mut file = File::create("foo.txt").log_expect("Error creating file");
# Error will be logged with the error! macro
[ERROR] Error creating file: Os { code: 2, kind: NotFound, message: "No such file or directory" }

# Main program panic'ing with same message
thread 'main' panicked at 'Error creating file: Os { code: 2, kind: NotFound, message: "No such file or directory" }', test.rs:4:48
Commit count: 19

cargo fmt