|
1 | | -use thiserror::Error; |
2 | | - |
3 | 1 | mod macros; |
4 | 2 |
|
5 | 3 | #[allow(dead_code)] |
@@ -47,52 +45,73 @@ pub use treeseq::TreeSequence; |
47 | 45 |
|
48 | 46 | use traits::TskTeardown; |
49 | 47 |
|
50 | | -#[derive(Error, Debug)] |
51 | 48 | #[non_exhaustive] |
| 49 | +#[derive(Debug)] |
52 | 50 | pub enum TskitError { |
53 | 51 | /// Returned when conversion attempts fail |
54 | | - #[error("range error: {}", *.0)] |
| 52 | + //#[error("range error: {}", *.0)] |
55 | 53 | RangeError(String), |
56 | 54 | /// Used when bad input is encountered. |
57 | | - #[error("we received {} but expected {}",*got, *expected)] |
| 55 | + //#[error("we received {} but expected {}",*got, *expected)] |
58 | 56 | ValueError { got: String, expected: String }, |
59 | 57 | /// Used when array access is out of range. |
60 | 58 | /// Typically, this is used when accessing |
61 | 59 | /// arrays allocated on the C side. |
62 | | - #[error("Invalid index")] |
| 60 | + //#[error("Invalid index")] |
63 | 61 | IndexError, |
64 | 62 | /// Raised when samples are requested from |
65 | 63 | /// [`crate::Tree`] objects, but sample lists are |
66 | 64 | /// not being updated. |
67 | | - #[error("Not tracking samples in Trees")] |
| 65 | + //#[error("Not tracking samples in Trees")] |
68 | 66 | NotTrackingSamples, |
69 | 67 | /// Wrapper around tskit C API error codes. |
70 | | - #[error("{}", get_tskit_error_message(*code))] |
| 68 | + //#[error("{}", get_tskit_error_message(*code))] |
71 | 69 | ErrorCode { code: i32 }, |
72 | 70 | /// A redirection of [``crate::metadata::MetadataError``] |
73 | | - #[error("{value:?}")] |
| 71 | + //#[error("{value:?}")] |
74 | 72 | MetadataError { |
75 | 73 | /// The redirected error |
76 | | - #[from] |
| 74 | + // #[from] |
77 | 75 | value: MetadataError, |
78 | 76 | }, |
79 | 77 | /// General error variant |
80 | | - #[error("{}", *.0)] |
| 78 | + //#[error("{}", *.0)] |
81 | 79 | LibraryError(String), |
82 | 80 | } |
83 | 81 |
|
84 | | -#[derive(Error, Debug)] |
| 82 | +impl std::fmt::Display for TskitError { |
| 83 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 84 | + todo!() |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +impl From<MetadataError> for TskitError { |
| 89 | + fn from(value: MetadataError) -> Self { |
| 90 | + Self::MetadataError { value } |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +impl std::error::Error for TskitError {} |
| 95 | + |
| 96 | +#[derive(Debug)] |
85 | 97 | #[non_exhaustive] |
86 | 98 | pub enum MetadataError { |
87 | 99 | /// Error related to types implementing |
88 | 100 | /// metadata serialization. |
89 | | - #[error("{}", *value)] |
| 101 | + // #[error("{}", *value)] |
90 | 102 | RoundtripError { |
91 | | - #[from] |
92 | 103 | value: Box<dyn std::error::Error + Send + Sync>, |
93 | 104 | }, |
94 | 105 | } |
95 | 106 |
|
| 107 | +impl std::fmt::Display for MetadataError { |
| 108 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 109 | + todo!() |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +impl std::error::Error for MetadataError {} |
| 114 | + |
96 | 115 | //#[non_exhaustive] |
97 | 116 | //#[derive(Error, Debug)] |
98 | 117 | //pub enum Error { |
|
0 commit comments