This is a follow-up from discussion from #168, and issue #169.
I suggest to redo simple API error type from boxed dyn error to an enum with a few variants:
- reader error
- deserializer error
- <any other struson-specific error variants>
- misc/custom (with boxed dyn error)
If #169 and this is implemented, initial code I posted to #169 could become super short:
#[derive(thiserror::Error, Debug)]
pub(in crate::phb) enum PhbParseError {
#[error("reading failed: {0}")]
ReadFailed(String),
#[error("parsing failed: {0}")]
ParseFailed(String),
}
impl From<struson::reader::HybridReaderError> for PhbParseError {
fn from(error: struson::reader::HybridReaderError) -> Self {
match error.is_io() {
true => Self::ReadFailed(error.to_string()),
false => Self::ParseFailed(error.to_string()),
}
}
}
This is a follow-up from discussion from #168, and issue #169.
I suggest to redo simple API error type from boxed dyn error to an enum with a few variants:
If #169 and this is implemented, initial code I posted to #169 could become super short: