mirror of
https://github.com/haraldh/chainerror.git
synced 2025-06-05 07:44:36 +02:00
feat: add annotate()
method to Context
to just annotate the passed error with location data Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
This commit is contained in:
parent
101d2074e1
commit
46b7f58e72
2 changed files with 38 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
use chainerror::prelude::v2::*;
|
||||
use chainerror::Context as _;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
|
@ -8,12 +8,17 @@ fn do_some_io() -> Result<(), Box<dyn Error + Send + Sync>> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn func3() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
fn func4() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
let filename = "foo.txt";
|
||||
do_some_io().context(format!("Error reading '{}'", filename))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn func3() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
func4().annotate()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
chainerror::str_context!(Func2Error);
|
||||
|
||||
fn func2() -> chainerror::Result<(), Func2Error> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue