use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ClientContractError {
#[error("client contract version must be positive")]
InvalidVersion,
#[error("client request id must be a 1-128 byte ASCII token")]
InvalidRequestId,
#[error("client idempotency key must be an 8-128 byte ASCII token")]
InvalidIdempotencyKey,
#[error("client failure code must be a bounded lowercase dotted identifier")]
InvalidFailureCode,
#[error("client version offer must not be empty")]
EmptyVersionOffer,
#[error("client version offer exceeds 16 entries")]
TooManyOfferedVersions,
#[error("client contract policy range or body limit is invalid")]
InvalidPolicy,
#[error("client and server have no mutually supported contract version")]
NoMutualVersion,
#[error(
"client contract version {received} is outside the supported range {minimum}..={current}"
)]
UnsupportedVersion {
received: u16,
minimum: u16,
current: u16,
},
#[error("client mutation requires an idempotency key")]
MissingIdempotencyKey,
#[error("client contract body exceeds the {maximum}-byte maximum")]
BodyTooLarge {
maximum: usize,
},
#[error("client contract JSON is invalid")]
InvalidJson(#[source] serde_json::Error),
#[error("client contract JSON encoding failed")]
EncodeJson(#[source] serde_json::Error),
}