pub type InvocationResult<T> = Result<T, InvocationError>;
pub type ProviderInitResult<T> = Result<T, ProviderInitError>;
#[derive(Debug, thiserror::Error)]
pub enum ProviderInitError {
#[error(transparent)]
Connect(#[from] async_nats::ConnectError),
#[error(transparent)]
Subscription(#[from] async_nats::SubscribeError),
#[error("Initialization error: {0}")]
Initialization(String),
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum InvocationError {
#[error(transparent)]
Validation(#[from] ValidationError),
#[error("Invocation timed out")]
Timeout,
#[error("Error when serializing invocation: {0:?}")]
Ser(#[from] rmp_serde::encode::Error),
#[error("Error while serializing/deserializing JSON: {0:?}")]
SerdeJson(#[from] serde_json::Error),
#[error("Error when deserializing invocation: {0:?}")]
Deser(#[from] rmp_serde::decode::Error),
#[error("Networking error during invocation: {0:?}")]
Network(#[from] NetworkError),
#[error("Error when chunking data: {0}")]
Chunking(String),
#[error("Malformed invocation: {0}")]
Malformed(String),
#[error("Unexpected error: {0}")]
Unexpected(String),
}
#[derive(Debug, thiserror::Error)]
pub enum ValidationError {
#[error("Issuer of this invocation is not in list of cluster issuers")]
InvalidIssuer,
#[error("Target of the invocation was {0}, which does not match the provider {1}")]
InvalidTarget(String, String),
#[error("Component {0} is not linked to this provider")]
InvalidComponent(String),
#[error("Invocation claims token expired")]
Expired,
#[error("Invocation claims signature invalid")]
InvalidSignature,
#[error("Invocation claims not valid yet")]
NotValidYet,
#[error("Invocation claims missing wascap metadata")]
MissingWascapClaims,
#[error("Invocation hash does not match claims hash")]
HashMismatch,
#[error("Invocation claims are not valid JSON")]
InvalidJson(String),
#[error("Invalid host ID: {0}")]
InvalidHostId(String),
#[error("Invocation claims and invocation target URL do not match: {0} != {1}")]
InvalidTargetUrl(String, String),
#[error("Invocation claims and invocation origin URL do not match: {0} != {1}")]
InvalidOriginUrl(String, String),
}
#[derive(Debug, thiserror::Error)]
pub enum NetworkError {
#[error(transparent)]
Publish(#[from] async_nats::PublishError),
#[error(transparent)]
Request(#[from] async_nats::RequestError),
}