fix: remove catch_unwind, add error logging
All checks were successful
BotServer CI/CD / build (push) Successful in 4m22s

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-05 00:26:44 -03:00
parent b277b032b0
commit 7a5f858d86

View file

@ -287,27 +287,23 @@ pub fn send_mail_keyword(state: Arc<AppState>, user: UserSession, engine: &mut E
let user_for_task = user_fn.clone(); let user_for_task = user_fn.clone();
std::thread::spawn(move || { std::thread::spawn(move || {
let result = std::panic::catch_unwind(|| { let rt = tokio::runtime::Builder::new_multi_thread()
let rt = tokio::runtime::Builder::new_multi_thread() .worker_threads(2)
.worker_threads(2) .enable_all()
.enable_all() .build();
.build();
if let Ok(rt) = rt { let result = if let Ok(rt) = rt {
rt.block_on(async move { match rt.block_on(async {
execute_send_mail(&state_for_task, &user_for_task, &to_str, &subject_str, &body_str, atts, None).await execute_send_mail(&state_for_task, &user_for_task, &to_str, &subject_str, &body_str, atts, None).await
}) }) {
} else { Ok(msg_id) => Ok(msg_id),
Err("Failed to build tokio runtime".to_string()) Err(e) => {
} log::error!("execute_send_mail error: {}", e);
}); Err(e)
}
let result = match result {
Ok(r) => r,
Err(e) => {
log::error!("send_mail thread panicked: {:?}", e);
Err(format!("send_mail thread panicked: {:?}", e))
} }
} else {
Err("Failed to build tokio runtime".to_string())
}; };
let _ = tx.send(result); let _ = tx.send(result);