handle libmcaptcha actor errors

This commit is contained in:
realaravinth
2021-08-20 18:15:55 +05:30
parent 6ef941f73d
commit 068c49080e
6 changed files with 50 additions and 26 deletions

View File

@@ -17,6 +17,7 @@
use std::convert::From;
use actix::MailboxError;
use actix_web::{
dev::BaseHttpResponseBuilder as HttpResponseBuilder,
error::ResponseError,
@@ -28,6 +29,7 @@ use derive_more::{Display, Error};
use lettre::transport::smtp::Error as SmtpError;
use libmcaptcha::errors::CaptchaError;
use serde::{Deserialize, Serialize};
use tokio::sync::oneshot::error::RecvError;
use url::ParseError;
use validator::ValidationErrors;
@@ -223,6 +225,24 @@ impl From<SmtpError> for ServiceError {
}
}
#[cfg(not(tarpaulin_include))]
impl From<RecvError> for ServiceError {
#[cfg(not(tarpaulin_include))]
fn from(e: RecvError) -> Self {
log::error!("{:?}", e);
ServiceError::InternalServerError
}
}
#[cfg(not(tarpaulin_include))]
impl From<MailboxError> for ServiceError {
#[cfg(not(tarpaulin_include))]
fn from(e: MailboxError) -> Self {
log::error!("{:?}", e);
ServiceError::InternalServerError
}
}
#[cfg(not(tarpaulin_include))]
pub type ServiceResult<V> = std::result::Result<V, ServiceError>;