use thiserror::Error;
use wick_interface_types::Type;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum CliError {
#[error(transparent)]
#[cfg(any(feature = "grpc", feature = "mesh"))]
RpcError(#[from] wick_rpc::Error),
#[error(transparent)]
IpAddrError(#[from] std::net::AddrParseError),
#[error(transparent)]
IOError(#[from] std::io::Error),
#[cfg(feature = "grpc")]
#[error(transparent)]
Config(#[from] wick_config::AssetError),
#[error(transparent)]
#[cfg(feature = "grpc")]
TransportError(#[from] tonic::transport::Error),
#[error(transparent)]
JoinError(#[from] tokio::task::JoinError),
#[error("invalid argument: {0}")]
InvalidArgument(String),
#[error("Input '{0}' not found in signature")]
InvalidInput(String),
#[error("{0}")]
Configuration(String),
#[error("Could not convert data '{data}' to a format suitable for port {port}'s type {ty}")]
Encoding {
data: String,
port: String,
ty: Type,
},
#[error("Found argument '{0}' which requires a value but no value was supplied")]
MissingArgumentValue(String),
}
impl CliError {
pub(crate) fn encoding<T: Into<String>, D: Into<String>>(port: T, data: D, ty: Type) -> Self {
Self::Encoding {
data: data.into(),
port: port.into(),
ty,
}
}
}