Skip to main content

simple_someip/protocol/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur when encoding, decoding, or validating SOME/IP messages.
4#[derive(Error, Debug)]
5#[non_exhaustive]
6pub enum Error {
7    /// An I/O error occurred while reading or writing bytes.
8    #[error("I/O error: {0:?}")]
9    Io(embedded_io::ErrorKind),
10    /// The input buffer ended before the expected number of bytes could be read.
11    #[error("Unexpected end of input")]
12    UnexpectedEof,
13    /// The protocol version field contains an unsupported value.
14    #[error("Invalid protocol version: {0:X}")]
15    InvalidProtocolVersion(u8),
16    /// The message type field contains an unrecognized value.
17    #[error("Invalid value in MessageType field: {0:X}")]
18    InvalidMessageTypeField(u8),
19    /// The return code field contains an unrecognized value.
20    #[error("Invalid value in ReturnCode field: {0:X}")]
21    InvalidReturnCode(u8),
22    /// The message ID is not supported by the payload implementation.
23    #[error("Unsupported MessageID  {0:X?}")]
24    UnsupportedMessageID(super::MessageId),
25    /// A service discovery (SD) error occurred.
26    #[error(transparent)]
27    Sd(#[from] super::sd::Error),
28}