From d7974773938a02f38c73aea09733f5ccf959d6e7 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Wed, 14 Dec 2022 13:22:13 +0100 Subject: [PATCH] feat: age no recipients error --- core/src/crypto.rs | 3 +-- core/src/error.rs | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/crypto.rs b/core/src/crypto.rs index c8344f1..de9c921 100644 --- a/core/src/crypto.rs +++ b/core/src/crypto.rs @@ -222,8 +222,7 @@ async fn age_encrypt_with_recipients( return Ok(()); } else { - // TODO: Error handling - unreachable!("No recipients provided"); + return Err(ServiceError::AgeNoRecipientsError); } } diff --git a/core/src/error.rs b/core/src/error.rs index 5949ec9..4be2274 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -40,6 +40,8 @@ pub enum ServiceError { CandidateDetailsNotSet, #[error("Tokio join error")] TokioJoinError(#[from] tokio::task::JoinError), + #[error("Age no recipients error")] + AgeNoRecipientsError, #[error("Age encrypt error")] AgeEncryptError(#[from] age::EncryptError), #[error("Age decrypt error")] @@ -88,6 +90,7 @@ impl ServiceError { ServiceError::CryptoEncryptFailed => 500, ServiceError::CryptoDecryptFailed => 500, ServiceError::CandidateDetailsNotSet => 500, + ServiceError::AgeNoRecipientsError => 500, ServiceError::AgeEncryptError(_) => 500, ServiceError::AgeDecryptError(_) => 500, ServiceError::AgeKeyError(_) => 500,