Crate thisctx[−][src]
Expand description
A simple crate work with thiserror to create errors with contexts, inspired by snafu.
Examples
use std::fs; use std::path::{Path, PathBuf}; use thisctx::{thisctx, ResultExt}; use thiserror::Error; thisctx! { #[derive(Debug, Error)] pub enum Error { #[error("I/O failed '{}': {src}", .ctx.0.display())] IoFaild { #[source] @source src: std::io::Error, @context ctx: #[derive(Debug)] struct (PathBuf), }, } } fn load_config(path: &Path) -> Result<String, Error> { fs::read_to_string(path).context(IoFaild(path)) }
Macros
thisctx |
Structs
NoneError |
Traits
IntoError | |
OptionExt | |
ResultExt |