[−][src]Trait tiny_fail::FailExt
A support trait for implementing rich error message.
This trait implemented for Option
and Result
.
You can
Example
use std::fs::File; use std::io::{BufRead, BufReader}; use tiny_fail::{Fail, FailExt}; fn foo() -> Result<(), Fail> { let f = File::open("not_exists.txt").context("failed open not_exists.txt")?; let r = BufReader::new(f); for line in r.lines() { let line = line.context("failed read line")?; let num = line.parse::<f64>().context(format!("failed parse \"{}\" into floating number", line))?; println!("{:.2}", num); } Ok(()) }