mcaptcha token generation unique constration err handling

This commit is contained in:
realaravinth
2021-04-11 11:17:15 +05:30
parent 08ec215709
commit 36b505ef59
2 changed files with 32 additions and 30 deletions

View File

@@ -196,19 +196,5 @@ impl From<sqlx::Error> for ServiceError {
}
}
pub fn dup_error(e: sqlx::Error, dup_error: ServiceError) -> ServiceError {
use sqlx::error::Error;
use std::borrow::Cow;
if let Error::Database(err) = e {
if err.code() == Some(Cow::from("23505")) {
dup_error
} else {
ServiceError::InternalServerError
}
} else {
ServiceError::InternalServerError
}
}
#[cfg(not(tarpaulin_include))]
pub type ServiceResult<V> = std::result::Result<V, ServiceError>;