httpsig/
error.rs

1use thiserror::Error;
2
3/// Result type for http signature
4pub type HttpSigResult<T> = std::result::Result<T, HttpSigError>;
5
6/// Error type for http signature
7#[derive(Error, Debug)]
8pub enum HttpSigError {
9  #[error("Base64 decode error: {0}")]
10  Base64DecodeError(#[from] base64::DecodeError),
11
12  /* ----- Crypto errors ----- */
13  /// Invalid private key for asymmetric algorithm
14  #[error("Failed to parse private key: {0}")]
15  ParsePrivateKeyError(String),
16  /// Invalid public key for asymmetric algorithm
17  #[error("Failed to parse public key: {0}")]
18  ParsePublicKeyError(String),
19  /// Signature parse error
20  #[error("Failed to parse signature: {0}")]
21  ParseSignatureError(String),
22  /// Invalid Signature
23  #[error("Invalid Signature: {0}")]
24  InvalidSignature(String),
25
26  /* ----- Component errors ----- */
27  /// Failed to parse structured field value
28  #[error("Failed to parse structured field value: {0}")]
29  ParseSFVError(String),
30  /// Invalid http message component name
31  #[error("Invalid http message component name: {0}")]
32  InvalidComponentName(String),
33  /// Invalid http message component param
34  #[error("Invalid http message component param: {0}")]
35  InvalidComponentParam(String),
36  /// Invalid http message component id
37  #[error("Invalid http message component id: {0}")]
38  InvalidComponentId(String),
39  /// Invalid http message component
40  #[error("Invalid http message component: {0}")]
41  InvalidComponent(String),
42
43  /* ----- Signature params errors ----- */
44  /// Invalid signature params
45  #[error("Invalid signature params: {0}")]
46  InvalidSignatureParams(String),
47
48  /// Error in building signature header
49  #[error("Failed to build signature header: {0}")]
50  BuildSignatureHeaderError(String),
51
52  /// Error in building signature base
53  #[error("Failed to build signature base: {0}")]
54  BuildSignatureBaseError(String),
55
56  /// Expired signature params
57  #[error("Expired signature params: {0}")]
58  ExpiredSignatureParams(String),
59
60  /* ----- Other errors ----- */
61  /// NotYetImplemented
62  #[error("Not yet implemented: {0}")]
63  NotYetImplemented(String),
64}