#[non_exhaustive]pub enum CcsdsNdmError {
Io(Error),
Format(Box<FormatError>),
Validation(Box<ValidationError>),
Epoch(EpochError),
UnsupportedMessage(String),
UnexpectedEof {
context: String,
},
}Expand description
The top-level error type for the CCSDS NDM library.
This enum wraps all possible errors that can occur during NDM parsing, validation, serialization, and I/O.
§Example: Handling Parse Errors
use ccsds_ndm::messages::opm::Opm;
use ccsds_ndm::error::CcsdsNdmError;
use ccsds_ndm::kvn::parser::ParseKvn;
match Opm::from_kvn_str("CCSDS_OPM_VERS = 3.0\n...") {
Ok(opm) => println!("Parsed: {:?}", opm),
Err(e) => {
if let Some(enum_err) = e.as_enum_error() {
eprintln!("Invalid enum value '{}' for field '{}'", enum_err.value, enum_err.field);
} else if let Some(validation_err) = e.as_validation_error() {
eprintln!("Validation error: {}", validation_err);
} else {
eprintln!("Error: {}", e);
}
}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Io(Error)
Errors occurring during I/O operations.
Format(Box<FormatError>)
Errors related to NDM format or syntax.
Validation(Box<ValidationError>)
Errors related to NDM data validation.
Epoch(EpochError)
Errors related to CCSDS Epochs.
UnsupportedMessage(String)
Error for unsupported CCSDS message types.
UnexpectedEof
Error when an unexpected end of input is reached.
Implementations§
Source§impl CcsdsNdmError
impl CcsdsNdmError
Sourcepub fn as_kvn_parse_error(&self) -> Option<&KvnParseError>
pub fn as_kvn_parse_error(&self) -> Option<&KvnParseError>
Returns the inner KVN parse error if this is a FormatError::Kvn.
Sourcepub fn as_validation_error(&self) -> Option<&ValidationError>
pub fn as_validation_error(&self) -> Option<&ValidationError>
Returns the inner validation error if this is a ValidationError.
Sourcepub fn as_format_error(&self) -> Option<&FormatError>
pub fn as_format_error(&self) -> Option<&FormatError>
Returns the inner format error if this is a FormatError.
Sourcepub fn as_epoch_error(&self) -> Option<&EpochError>
pub fn as_epoch_error(&self) -> Option<&EpochError>
Returns the inner epoch error if this is an EpochError.
Sourcepub fn as_io_error(&self) -> Option<&Error>
pub fn as_io_error(&self) -> Option<&Error>
Returns the inner I/O error if this is an IoError.
Sourcepub fn as_xml_error(&self) -> Option<&Error>
pub fn as_xml_error(&self) -> Option<&Error>
Returns the inner XML error if this is an XmlError.
Sourcepub fn is_format_error(&self) -> bool
pub fn is_format_error(&self) -> bool
Returns true if this is any FormatError.
Sourcepub fn is_kvn_error(&self) -> bool
pub fn is_kvn_error(&self) -> bool
Returns true if this is a KVN FormatError.
Sourcepub fn is_validation_error(&self) -> bool
pub fn is_validation_error(&self) -> bool
Returns true if this is a ValidationError.
Sourcepub fn is_io_error(&self) -> bool
pub fn is_io_error(&self) -> bool
Returns true if this is an I/O error.
Sourcepub fn is_epoch_error(&self) -> bool
pub fn is_epoch_error(&self) -> bool
Returns true if this is an epoch error.
Sourcepub fn as_enum_error(&self) -> Option<&EnumParseError>
pub fn as_enum_error(&self) -> Option<&EnumParseError>
Returns the inner EnumParseError if this is a FormatError::Enum.
Sourcepub fn as_parse_int_error(&self) -> Option<&ParseIntError>
pub fn as_parse_int_error(&self) -> Option<&ParseIntError>
Returns the inner ParseIntError if this is a FormatError::ParseInt.
Sourcepub fn as_parse_float_error(&self) -> Option<&ParseFloatError>
pub fn as_parse_float_error(&self) -> Option<&ParseFloatError>
Returns the inner ParseFloatError if this is a FormatError::ParseFloat.
Sourcepub fn with_location(self, input: &str, offset: usize) -> Self
pub fn with_location(self, input: &str, offset: usize) -> Self
Populates location information for variants with line info.
Trait Implementations§
Source§impl AddContext<&str, StrContext> for CcsdsNdmError
impl AddContext<&str, StrContext> for CcsdsNdmError
Source§fn add_context(
self,
_input: &&str,
_token: &<&str as Stream>::Checkpoint,
context: StrContext,
) -> Self
fn add_context( self, _input: &&str, _token: &<&str as Stream>::Checkpoint, context: StrContext, ) -> Self
Source§impl Debug for CcsdsNdmError
impl Debug for CcsdsNdmError
Source§impl Display for CcsdsNdmError
impl Display for CcsdsNdmError
Source§impl Error for CcsdsNdmError
impl Error for CcsdsNdmError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<Box<FormatError>> for CcsdsNdmError
impl From<Box<FormatError>> for CcsdsNdmError
Source§fn from(source: Box<FormatError>) -> Self
fn from(source: Box<FormatError>) -> Self
Source§impl From<Box<ValidationError>> for CcsdsNdmError
impl From<Box<ValidationError>> for CcsdsNdmError
Source§fn from(source: Box<ValidationError>) -> Self
fn from(source: Box<ValidationError>) -> Self
Source§impl From<DeError> for CcsdsNdmError
impl From<DeError> for CcsdsNdmError
Source§impl From<EnumParseError> for CcsdsNdmError
impl From<EnumParseError> for CcsdsNdmError
Source§fn from(e: EnumParseError) -> Self
fn from(e: EnumParseError) -> Self
Source§impl From<EpochError> for CcsdsNdmError
impl From<EpochError> for CcsdsNdmError
Source§fn from(source: EpochError) -> Self
fn from(source: EpochError) -> Self
Source§impl From<Error> for CcsdsNdmError
impl From<Error> for CcsdsNdmError
Source§impl From<Error> for CcsdsNdmError
impl From<Error> for CcsdsNdmError
Source§impl From<FormatError> for CcsdsNdmError
impl From<FormatError> for CcsdsNdmError
Source§fn from(e: FormatError) -> Self
fn from(e: FormatError) -> Self
Source§impl From<ParseFloatError> for CcsdsNdmError
impl From<ParseFloatError> for CcsdsNdmError
Source§fn from(e: ParseFloatError) -> Self
fn from(e: ParseFloatError) -> Self
Source§impl From<ParseIntError> for CcsdsNdmError
impl From<ParseIntError> for CcsdsNdmError
Source§fn from(e: ParseIntError) -> Self
fn from(e: ParseIntError) -> Self
Source§impl From<SeError> for CcsdsNdmError
impl From<SeError> for CcsdsNdmError
Source§impl From<ValidationError> for CcsdsNdmError
impl From<ValidationError> for CcsdsNdmError
Source§fn from(e: ValidationError) -> Self
fn from(e: ValidationError) -> Self
Source§impl FromExternalError<&str, CcsdsNdmError> for InternalParserError
impl FromExternalError<&str, CcsdsNdmError> for InternalParserError
Source§fn from_external_error(input: &&str, e: CcsdsNdmError) -> Self
fn from_external_error(input: &&str, e: CcsdsNdmError) -> Self
ParserError::from_input but also include an external error.Source§impl FromExternalError<&str, EpochError> for CcsdsNdmError
impl FromExternalError<&str, EpochError> for CcsdsNdmError
Source§fn from_external_error(_input: &&str, e: EpochError) -> Self
fn from_external_error(_input: &&str, e: EpochError) -> Self
ParserError::from_input but also include an external error.Source§impl FromExternalError<&str, ParseFloatError> for CcsdsNdmError
impl FromExternalError<&str, ParseFloatError> for CcsdsNdmError
Source§fn from_external_error(_input: &&str, e: ParseFloatError) -> Self
fn from_external_error(_input: &&str, e: ParseFloatError) -> Self
ParserError::from_input but also include an external error.Source§impl FromExternalError<&str, ParseIntError> for CcsdsNdmError
impl FromExternalError<&str, ParseIntError> for CcsdsNdmError
Source§fn from_external_error(_input: &&str, e: ParseIntError) -> Self
fn from_external_error(_input: &&str, e: ParseIntError) -> Self
ParserError::from_input but also include an external error.