-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from mdsol/errors-to-thiserror
Convert from anyhow to thiserror
- Loading branch information
Showing
7 changed files
with
65 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use thiserror::Error; | ||
|
||
/// All of the possible errors that can happen while performing mauth operations | ||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
/// A UTF8 decode error while attempting to process the URL | ||
#[error("Unable to handle the URL as the format was invalid: {0}")] | ||
UrlEncodingError(#[from] std::string::FromUtf8Error), | ||
/// A MAuth version that is not supported was requested | ||
#[error("Version {0} is not supported")] | ||
UnsupportedVersion(u8), | ||
/// The provided private key could not be parsed | ||
#[error("Unable to parse RSA private key: {0}")] | ||
PrivateKeyDecodeError(#[from] rsa::pkcs1::Error), | ||
/// The provided public key could not be parsed | ||
#[error("Unable to parse RSA public key: {0}")] | ||
PublicKeyDecodeError(#[from] spki::Error), | ||
/// An algorithm failure occurred while trying to sign a request | ||
#[error("RSA algorithm error: {0}")] | ||
RsaSignError(#[from] rsa::Error), | ||
/// An algorithm failure occurred while trying to verify a request | ||
#[error("Unable to verify RSA signature: {0}")] | ||
SignatureVerifyError(#[from] rsa::signature::Error), | ||
/// A base64 error was encountered while attempting to verify a v1 signature | ||
#[error("Unable to decode base64-encoded signature: {0}")] | ||
SignatureDecodeError(#[from] base64::DecodeError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
pub mod signable; | ||
/// Error types | ||
pub mod error; | ||
pub(crate) mod signable; | ||
/// Signing for outgoing requests | ||
pub mod signer; | ||
/// Signature verification for incoming requests | ||
pub mod verifier; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters