wasmcloud_provider_sdk/
error.rs1pub type InvocationResult<T> = Result<T, InvocationError>;
4pub type ProviderInitResult<T> = Result<T, ProviderInitError>;
5
6#[derive(Debug, thiserror::Error)]
9pub enum ProviderInitError {
10 #[error(transparent)]
12 Connect(#[from] async_nats::ConnectError),
13 #[error(transparent)]
15 Subscription(#[from] async_nats::SubscribeError),
16 #[error("Initialization error: {0}")]
18 Initialization(String),
19}
20
21#[derive(Debug, thiserror::Error)]
24#[non_exhaustive]
25pub enum InvocationError {
26 #[error(transparent)]
28 Validation(#[from] ValidationError),
29 #[error("Invocation timed out")]
31 Timeout,
32 #[error("Error when serializing invocation: {0:?}")]
34 Ser(#[from] rmp_serde::encode::Error),
38 #[error("Error while serializing/deserializing JSON: {0:?}")]
39 SerdeJson(#[from] serde_json::Error),
41 #[error("Error when deserializing invocation: {0:?}")]
43 Deser(#[from] rmp_serde::decode::Error),
44 #[error("Networking error during invocation: {0:?}")]
46 Network(#[from] NetworkError),
47 #[error("Error when chunking data: {0}")]
49 Chunking(String),
50 #[error("Malformed invocation: {0}")]
52 Malformed(String),
53 #[error("Unexpected error: {0}")]
55 Unexpected(String),
56}
57
58#[derive(Debug, thiserror::Error)]
60pub enum ValidationError {
61 #[error("Issuer of this invocation is not in list of cluster issuers")]
63 InvalidIssuer,
64 #[error("Target of the invocation was {0}, which does not match the provider {1}")]
66 InvalidTarget(String, String),
67 #[error("Component {0} is not linked to this provider")]
69 InvalidComponent(String),
70 #[error("Invocation claims token expired")]
72 Expired,
73 #[error("Invocation claims signature invalid")]
75 InvalidSignature,
76 #[error("Invocation claims not valid yet")]
78 NotValidYet,
79 #[error("Invocation claims missing wascap metadata")]
81 MissingWascapClaims,
82 #[error("Invocation hash does not match claims hash")]
84 HashMismatch,
85 #[error("Invocation claims are not valid JSON")]
87 InvalidJson(String),
88 #[error("Invalid host ID: {0}")]
90 InvalidHostId(String),
91 #[error("Invocation claims and invocation target URL do not match: {0} != {1}")]
93 InvalidTargetUrl(String, String),
94 #[error("Invocation claims and invocation origin URL do not match: {0} != {1}")]
96 InvalidOriginUrl(String, String),
97}
98
99#[derive(Debug, thiserror::Error)]
102pub enum NetworkError {
103 #[error(transparent)]
104 Publish(#[from] async_nats::PublishError),
105 #[error(transparent)]
106 Request(#[from] async_nats::RequestError),
107}