More properly return import errors
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Pierre HUBERT 2023-08-25 15:14:59 +02:00
parent 71ae2df2d7
commit 1c1f2cc710
2 changed files with 9 additions and 5 deletions

View File

@ -182,7 +182,12 @@ pub async fn import_family(
req_member_data.mother = members_id_mapping.get(&i).copied(); req_member_data.mother = members_id_mapping.get(&i).copied();
} }
req_member_data.to_member(member).await?; if let Err(e) = req_member_data.to_member(member).await {
log::error!("Error while processing import (member {:?}) - {e}", req_id);
return Ok(
HttpResponse::BadRequest().json(format!("Failed to validate member {:?}!", req_id))
);
}
if let Some(id) = req_member.photo_id { if let Some(id) = req_member.photo_id {
photos_to_insert.push(PhotoToProcess { photos_to_insert.push(PhotoToProcess {

View File

@ -5,7 +5,6 @@ use crate::extractors::member_extractor::FamilyAndMemberInPath;
use crate::models::{Member, MemberID, PhotoID, Sex}; use crate::models::{Member, MemberID, PhotoID, Sex};
use crate::services::{members_service, photos_service}; use crate::services::{members_service, photos_service};
use crate::utils::countries_utils; use crate::utils::countries_utils;
use crate::utils::encode_utils::base64_enc;
use actix_multipart::form::tempfile::TempFile; use actix_multipart::form::tempfile::TempFile;
use actix_multipart::form::MultipartForm; use actix_multipart::form::MultipartForm;
use actix_web::{web, HttpResponse}; use actix_web::{web, HttpResponse};
@ -63,8 +62,8 @@ enum MemberControllerErr {
MalformedBirthLastname, MalformedBirthLastname,
#[error("Malformed email address!")] #[error("Malformed email address!")]
MalformedEmailAddress, MalformedEmailAddress,
#[error("Invalid email address (base64={0}) !")] #[error("Invalid email address!")]
InvalidEmailAddress(String), InvalidEmailAddress,
#[error("Malformed phone number!")] #[error("Malformed phone number!")]
MalformedPhoneNumber, MalformedPhoneNumber,
#[error("Malformed address!")] #[error("Malformed address!")]
@ -133,7 +132,7 @@ impl MemberRequest {
if let Some(mail) = &self.email { if let Some(mail) = &self.email {
if !mailchecker::is_valid(mail) { if !mailchecker::is_valid(mail) {
return Err(MemberControllerErr::InvalidEmailAddress(base64_enc(mail)).into()); return Err(MemberControllerErr::InvalidEmailAddress.into());
} }
} }