1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/// Represents the kind of error after downcasting [`BoxedError2`](crate::BoxedError2).
///
/// Used to distinguish between standard library errors and Error2 errors
/// when downcasting type-erased errors.
///
/// # Variants
///
/// - `Std`: Error from `std::error::Error` (has its own backtrace)
/// - `Err2`: Error implementing [`Error2`](crate::Error2) (reuses parent backtrace)
///
/// # Example
///
/// ```
/// use std::io;
///
/// use error2::{kind::ErrorKind, prelude::*};
///
/// # fn example() -> Result<(), BoxedError2> {
/// let err = std::io::Error::from(std::io::ErrorKind::NotFound);
/// let boxed = BoxedError2::from_std(err);
///
/// // Downcast to get the ErrorKind
/// match boxed.downcast_ref::<io::Error>() {
/// Some(ErrorKind::Std { source, backtrace }) => {
/// println!("Std error: {}", source);
/// }
/// Some(ErrorKind::Err2 { source }) => {
/// println!("Error2: {}", source);
/// }
/// None => {}
/// }
/// # Ok(())
/// # }
/// ```