ara_com/error.rs
1//! Unified error type for all `ara-com` operations.
2
3use crate::types::*;
4use thiserror::Error;
5
6/// Error type returned by all `ara-com` and transport-backend operations.
7///
8/// Variants cover transport failures, serialization issues, service
9/// discovery problems, and protocol-level errors. Transport backends
10/// may convert their own error types into `AraComError` via `From` impls.
11#[derive(Error, Debug)]
12pub enum AraComError {
13 /// A transport-level failure (e.g. socket closed, send failed).
14 #[error("transport error: {message}")]
15 Transport { message: String },
16
17 /// A value could not be encoded to the SOME/IP wire format.
18 #[error("serialization error: {message}")]
19 Serialization { message: String },
20
21 /// A received payload could not be decoded from the wire format.
22 #[error("deserialization error: {message}")]
23 Deserialization { message: String },
24
25 /// The requested service instance was not found or is offline.
26 #[error("service {service_id:?} instance {instance_id:?} not available")]
27 ServiceNotAvailable {
28 service_id: ServiceId,
29 instance_id: InstanceId,
30 },
31
32 /// A request/response call exceeded the configured timeout.
33 #[error("method call timed out after {timeout_ms}ms")]
34 Timeout { timeout_ms: u64 },
35
36 /// A service-discovery operation failed (e.g. multicast unreachable).
37 #[error("service discovery error: {message}")]
38 Discovery { message: String },
39
40 /// An event-group subscription was rejected or could not be established.
41 #[error("subscription error: {message}")]
42 Subscription { message: String },
43
44 /// An application-level error returned by the server in a response.
45 #[error("application error: code={code}, message={message}")]
46 Application { code: u8, message: String },
47
48 /// A SOME/IP protocol-level error indicated by the return code.
49 #[error("protocol error: return_code={return_code:?}")]
50 Protocol {
51 return_code: crate::transport::ReturnCode,
52 },
53
54 /// An underlying I/O error (e.g. socket bind failure).
55 #[error("IO error: {0}")]
56 Io(#[from] std::io::Error),
57}