Merge pull request #3211 from nymtech/feature/no_creds_err_msg

Better error log for lacking credential in db
This commit is contained in:
Tommy Verrall
2023-03-24 11:18:41 +03:00
committed by GitHub
3 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -48,12 +48,12 @@ impl CoconutCredentialManager {
/// Tries to retrieve one of the stored, unused credentials.
pub(crate) async fn get_next_coconut_credential(
&self,
) -> Result<CoconutCredential, sqlx::Error> {
) -> Result<Option<CoconutCredential>, sqlx::Error> {
sqlx::query_as!(
CoconutCredential,
"SELECT * FROM coconut_credentials WHERE NOT consumed"
)
.fetch_one(&self.connection_pool)
.fetch_optional(&self.connection_pool)
.await
}
+3
View File
@@ -13,4 +13,7 @@ pub enum StorageError {
#[error("Inconsistent data in database")]
InconsistentData,
#[error("No unused credential in database. You need to buy at least one")]
NoCredential,
}
+2 -1
View File
@@ -90,7 +90,8 @@ impl Storage for PersistentStorage {
let credential = self
.coconut_credential_manager
.get_next_coconut_credential()
.await?;
.await?
.ok_or(StorageError::NoCredential)?;
Ok(credential)
}