mirror of
https://github.com/haraldh/chainerror.git
synced 2025-05-31 13:58:07 +02:00
make ChainError Send + Sync
This commit is contained in:
parent
51af6da378
commit
a558c35ba4
20 changed files with 84 additions and 85 deletions
|
@ -8,7 +8,7 @@ a `std::error::Error`.
|
|||
Not using `String` errors anymore, the `cherr!()` macro seen in the beginning of
|
||||
the tutorial has to be used again.
|
||||
|
||||
Only returning `Func1ErrorKind` in `func1()` now let us get rid of `Result<(), Box<Error>>` and we can
|
||||
Only returning `Func1ErrorKind` in `func1()` now let us get rid of `Result<(), Box<Error + Send + Sync>>` and we can
|
||||
use `ChainResult<(), Func1ErrorKind>`.
|
||||
|
||||
In `main` we can now directly use the methods of `ChainError<T>` without downcasting the error first.
|
||||
|
|
|
@ -24,7 +24,7 @@ along with the filename (`file!()`) and line number (`line!()`)
|
|||
and returns `newerror`.
|
||||
|
||||
`Err()?` then returns the inner error applying `.into()`, so that we
|
||||
again have a `Err(Box<Error>)` as a result.
|
||||
again have a `Err(Box<Error + Send + Sync>)` as a result.
|
||||
|
||||
The `Debug` implementation of `ChainError<T>` (which is returned by `cherr!()`)
|
||||
prints the `Debug` of `T` prefixed with the stored filename and line number.
|
||||
|
|
|
@ -7,7 +7,7 @@ In this example `func1()` can return either `Func1ErrorFunc2` or `Func1ErrorIO`.
|
|||
We might want to `match` on `func1()` with something like:
|
||||
|
||||
~~~rust,ignore
|
||||
fn main() -> Result<(), Box<Error>> {
|
||||
fn main() -> Result<(), Box<Error + Send + Sync>> {
|
||||
match func1() {
|
||||
Err(e) if let Some(s) = e.downcast_chain_ref::<Func1ErrorIO>() =>
|
||||
eprintln!("Func1ErrorIO:\n{:?}", s),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue