use std::str::Utf8Error;
use thiserror::Error;
use wasmparser::BinaryReaderError;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("Invalid module hash")]
InvalidModuleHash,
#[error("Invalid module format, the 'jwt' custom section is missing")]
InvalidModuleFormat,
#[error(transparent)]
Utf8Error(#[from] Utf8Error),
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
ParserReadError(#[from] BinaryReaderError),
#[error("Parse error for wasm module: {0}")]
ParseError(String),
#[error("General error : {0}")]
Other(String),
#[error("Invalid token format")]
Token,
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error(transparent)]
Base64(#[from] base64::DecodeError),
#[error(transparent)]
Sign(#[from] nkeys::error::Error),
#[error("{0} not utf8 bytes")]
Utf8(String),
#[error("Token is not yet valid")]
TokenTooEarly,
#[error("Token has expired")]
ExpiredToken,
#[error("Token is missing an issuer")]
MissingIssuer,
#[error("Token is missing a subject")]
MissingSubject,
#[error("Token uses an invalid algorithm")]
InvalidAlgorithm,
}