fix: remove catch_unwind, add error logging
All checks were successful
BotServer CI/CD / build (push) Successful in 4m22s
All checks were successful
BotServer CI/CD / build (push) Successful in 4m22s
This commit is contained in:
parent
b277b032b0
commit
7a5f858d86
1 changed files with 15 additions and 19 deletions
|
|
@ -287,27 +287,23 @@ pub fn send_mail_keyword(state: Arc<AppState>, user: UserSession, engine: &mut E
|
|||
let user_for_task = user_fn.clone();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
let result = std::panic::catch_unwind(|| {
|
||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(2)
|
||||
.enable_all()
|
||||
.build();
|
||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(2)
|
||||
.enable_all()
|
||||
.build();
|
||||
|
||||
if let Ok(rt) = rt {
|
||||
rt.block_on(async move {
|
||||
execute_send_mail(&state_for_task, &user_for_task, &to_str, &subject_str, &body_str, atts, None).await
|
||||
})
|
||||
} else {
|
||||
Err("Failed to build tokio runtime".to_string())
|
||||
}
|
||||
});
|
||||
|
||||
let result = match result {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
log::error!("send_mail thread panicked: {:?}", e);
|
||||
Err(format!("send_mail thread panicked: {:?}", e))
|
||||
let result = if let Ok(rt) = rt {
|
||||
match rt.block_on(async {
|
||||
execute_send_mail(&state_for_task, &user_for_task, &to_str, &subject_str, &body_str, atts, None).await
|
||||
}) {
|
||||
Ok(msg_id) => Ok(msg_id),
|
||||
Err(e) => {
|
||||
log::error!("execute_send_mail error: {}", e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Err("Failed to build tokio runtime".to_string())
|
||||
};
|
||||
|
||||
let _ = tx.send(result);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue