diff options
author | Cara Salter <cara@devcara.com> | 2022-06-28 07:47:29 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-06-28 07:47:29 -0400 |
commit | 2dea604581cafbfbb73443ec2449cda391d12ab7 (patch) | |
tree | a1cb6a43f6ca0ac79de0bf525d776057156b500e /src/errors.rs | |
parent | 8de1eae2b49d763dcac55b8a2a84673475a35e63 (diff) | |
download | solard-2dea604581cafbfbb73443ec2449cda391d12ab7.tar.gz solard-2dea604581cafbfbb73443ec2449cda391d12ab7.zip |
auth: Initial implementation of auth/begin
Diffstat (limited to 'src/errors.rs')
-rw-r--r-- | src/errors.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/errors.rs b/src/errors.rs index cbec046..f6e00e2 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,3 +1,5 @@ +use hex::FromHexError; +use ring::error::KeyRejected; use thiserror::Error; use axum::response::{Response, IntoResponse}; @@ -5,6 +7,8 @@ use axum::http::StatusCode; use axum::body; use axum::Json; +use ring::error::Unspecified as RingUnspecified; + #[derive(Debug, Error)] pub enum ServiceError { #[error("Solarlib error: {0}")] @@ -28,12 +32,25 @@ pub enum ServiceError { #[error("Generic: {0}")] Generic(String), - #[error("Paseto: {0}")] - Paseto(#[from] pasetors::errors::Error), + #[error("Invalid PASETO Key: {0}")] + PasetoInvalid(#[from] KeyRejected), +} + +impl From<FromHexError> for ServiceError { + fn from(_: FromHexError) -> Self { + ServiceError::Generic(String::from("Could not convert from hex")) + } } +impl From<RingUnspecified> for ServiceError { + fn from(_: RingUnspecified) -> Self { + ServiceError::Generic("Unspecified RNG error".to_string()) + } +} pub type StringResult<T = &'static str> = std::result::Result<T, ServiceError>; +pub type TokenResult<T = String> = std::result::Result<T, ServiceError>; + pub type JsonResult<T> = std::result::Result<T, ServiceError>; pub type NoneResult = std::result::Result<(), ServiceError>; |