use pontifex::{ChannelError, attestation};
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid {attribute}: {reason}")]
InvalidConfig {
attribute: String,
reason: String,
},
#[error("failed to parse config: {0}")]
MalformedConfig(String),
#[error("failed to build HTTP client: {0}")]
Transport(#[source] reqwest::Error),
#[error("request to the host failed: {0}")]
Request(#[source] reqwest::Error),
#[error("host returned HTTP {0}")]
Status(u16),
#[error("response was not valid JSON: {0}")]
MalformedResponse(#[source] reqwest::Error),
#[error(transparent)]
Attestation(#[from] attestation::Error),
#[error("assignment document or public key was not valid base64")]
MalformedAssignment,
#[error("host returned HTTP {status} ({code})")]
Api {
status: u16,
code: String,
allow_retry: bool,
},
#[error("the request was not sealed to the enclave's current key; re-assign and retry once")]
ReassignRequired,
#[error("sealed channel failure: {0:?}")]
Channel(#[source] ChannelError),
#[error("response ciphertext was not valid base64")]
MalformedCiphertext,
#[error("sealed response was not a match result")]
MalformedResult,
#[error("attested signing public key was invalid")]
InvalidSigningKey,
#[error("match statement did not verify under the attested signing key")]
StatementInvalid,
}