refactor(storage_models, errors): impl StorageErrorExt for error_stack::Result<T, errors::StorageError> (#886)

This commit is contained in:
Abhishek
2023-04-18 00:01:13 +05:30
committed by GitHub
parent 298a0a4956
commit b4020294cc
23 changed files with 125 additions and 268 deletions

View File

@ -179,7 +179,7 @@ pub async fn update_api_key(
let api_key = store
.update_api_key(key_id.to_owned(), api_key.foreign_into())
.await
.map_err(|err| err.to_not_found_response(errors::ApiErrorResponse::ApiKeyNotFound))?;
.to_not_found_response(errors::ApiErrorResponse::ApiKeyNotFound)?;
Ok(ApplicationResponse::Json(api_key.foreign_into()))
}
@ -192,7 +192,7 @@ pub async fn revoke_api_key(
let revoked = store
.revoke_api_key(key_id)
.await
.map_err(|err| err.to_not_found_response(errors::ApiErrorResponse::ApiKeyNotFound))?;
.to_not_found_response(errors::ApiErrorResponse::ApiKeyNotFound)?;
metrics::API_KEY_REVOKED.add(&metrics::CONTEXT, 1, &[]);