wadm_client/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, ClientError>;
4
5/// Errors that can occur when interacting with the wadm client.
6#[derive(Error, Debug)]
7pub enum ClientError {
8    /// Unable to load the manifest from a given source. The underlying error is anyhow::Error to
9    /// allow for flexibility in loading from different sources.
10    #[error("Unable to load manifest: {0:?}")]
11    ManifestLoad(anyhow::Error),
12    /// An error occurred with the NATS transport
13    #[error(transparent)]
14    NatsError(#[from] async_nats::RequestError),
15    /// An API error occurred with the request
16    #[error("Invalid request: {0}")]
17    ApiError(String),
18    /// The named model was not found
19    #[error("Model not found: {0}")]
20    NotFound(String),
21    /// Unable to serialize or deserialize YAML or JSON data.
22    #[error("Unable to parse manifest: {0:?}")]
23    Serialization(#[from] SerializationError),
24    /// Any other errors that are not covered by the other error cases
25    #[error(transparent)]
26    Other(#[from] anyhow::Error),
27}
28
29/// Errors that can occur when serializing or deserializing YAML or JSON data.
30#[derive(Error, Debug)]
31pub enum SerializationError {
32    #[error(transparent)]
33    Yaml(#[from] serde_yaml::Error),
34    #[error(transparent)]
35    Json(#[from] serde_json::Error),
36}