1
0
Fork 0
mirror of https://github.com/mCaptcha/mCaptcha.git synced 2025-05-03 13:42:49 +03:00

feat: implement accountnotfound and captcha notfound err vals for sqlx postgres

This commit is contained in:
realaravinth 2022-05-13 19:08:31 +05:30
parent 3edb2252af
commit ddb6d336f7
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
2 changed files with 17 additions and 1 deletions
db/db-sqlx-postgres/src

View file

@ -21,6 +21,15 @@ use std::borrow::Cow;
use db_core::dev::*;
use sqlx::Error;
/// map custom row not found error to DB error
pub fn map_row_not_found_err(e: Error, row_not_found: DBError) -> DBError {
if let Error::RowNotFound = e {
row_not_found
} else {
map_register_err(e)
}
}
/// map postgres errors to [DBError](DBError) types
pub fn map_register_err(e: Error) -> DBError {
if let Error::Database(err) = e {