Merge pull request #3211 from nymtech/feature/no_creds_err_msg
Better error log for lacking credential in db
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user