Simplified the downcasting implementations by replacing pointer casting logic with `std::mem::transmute`, ensuring type safety after matching. Added tests to validate various downcasting behaviors for both owned and trait-object error scenarios, improving overall reliability and test coverage.
Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
Introduced tests to verify the behavior of `AnnotatedError` in display, debug, and error chaining scenarios. Ensured proper formatting for standalone errors and preservation of the error chain for wrapped errors.
This commit adds a usage example demonstrating how to handle errors returned by the `func1` function in the main function. The example provides clarity on practical error handling and makes the documentation more comprehensive for users.
This commit introduces a series of unit tests to validate various error handling functionalities, including error chaining, root cause extraction, display/debug formatting, annotation, context mapping, downcasting, and custom error kinds. These tests improve code reliability and ensure expected behavior across different error scenarios.
It was causing the rust compiler to output the renamed structs in error
messages confusing users who don't know about the old renamed ones.
Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
- remove `Chain…` mentions in the docs
- add doc links
- add rustdoc feature to scrape the examples for code
Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
ChainErrorFrom and IntoChainError are not needed anymore with the
`#[track_caller]` feature.
Now, a proper `From<T> for ChainError<T>` can be implemented.
Line numbering has changed in Rust 1.71 in the doc tests, due to an
extra inserted `#[allow(unused_extern_crates)]` line.
Don't test for the exact line number anymore.
Signed-off-by: Harald Hoyer <harald@hoyer.xyz>