2018-12-20 16:37:08 +01:00
|
|
|
# The source() of Errors
|
2018-12-20 15:14:21 +01:00
|
|
|
|
|
|
|
Sometimes you want to inspect the `source()` of an `Error`.
|
|
|
|
`chainerror` implements `std::error::Error::source()`, so you can get the cause of an error.
|
|
|
|
|
2018-12-20 14:52:06 +01:00
|
|
|
~~~rust
|
2019-03-04 11:38:35 +01:00
|
|
|
{{#include ../examples/tutorial5.rs}}
|
2018-12-20 14:52:06 +01:00
|
|
|
# #[allow(dead_code)]
|
|
|
|
# mod chainerror {
|
2020-03-03 14:25:37 +01:00
|
|
|
{{#rustdoc_include ../src/lib.rs:-1}}
|
2018-12-20 14:52:06 +01:00
|
|
|
# }
|
2018-12-20 15:14:21 +01:00
|
|
|
~~~
|
|
|
|
|
2018-12-21 13:50:08 +01:00
|
|
|
Note, that because we changed the output of the error in `main()` from
|
|
|
|
`Debug` to `Display`, we don't see the error backtrace with filename and line number.
|
2018-12-20 15:14:21 +01:00
|
|
|
|
2023-07-28 16:21:22 +02:00
|
|
|
To use the `Display` backtrace, you have to use the alternative display format output `{:#}`.
|