diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-05-19 21:38:58 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-19 21:38:58 +0800 |
| commit | bd4b09b06181093c95e865b04d4a9cdda7dd0728 (patch) | |
| tree | aee9b76455ce4597e718f472b02e59086a802ce7 /mingling_core/src/program/once_exec.rs | |
| parent | 5d61201e9532cfc92f4b93e34b7c10a97cfb35df (diff) | |
Conditionally disable panic unwind support for async feature
Diffstat (limited to 'mingling_core/src/program/once_exec.rs')
| -rw-r--r-- | mingling_core/src/program/once_exec.rs | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/mingling_core/src/program/once_exec.rs b/mingling_core/src/program/once_exec.rs index b68eb01..e1c0956 100644 --- a/mingling_core/src/program/once_exec.rs +++ b/mingling_core/src/program/once_exec.rs @@ -1,8 +1,8 @@ use crate::THIS_PROGRAM; -use crate::{ - Program, ProgramCollect, RenderResult, - error::{ProgramExecuteError, ProgramPanic}, -}; +use crate::{Program, ProgramCollect, RenderResult, error::ProgramExecuteError}; + +#[cfg(not(feature = "async"))] +use crate::error::ProgramPanic; // Async program #[cfg(feature = "async")] @@ -25,11 +25,6 @@ where .downcast_ref::<Program<C>>() .unwrap(); - #[cfg(not(panic = "abort"))] - if program.stdout_setting.silence_panic { - std::panic::set_hook(Box::new(|_| {})); - } - f(program).await } @@ -43,33 +38,9 @@ where self.args = self.args.iter().skip(1).cloned().collect(); - #[cfg(panic = "abort")] return self .exec_wrapper(|p| async { crate::exec::exec(p).await.map_err(|e| e.into()) }) .await; - - #[cfg(not(panic = "abort"))] - match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - self.exec_wrapper(|p| async { crate::exec::exec(p).await.map_err(|e| e.into()) }) - })) { - Ok(fut) => fut.await, - Err(panic_info) => { - let panic_payload = ProgramPanic { - payload: panic_info, - }; - - let program = THIS_PROGRAM - .get() - .unwrap() - .as_ref() - .unwrap() - .downcast_ref::<Program<C>>() - .unwrap(); - - program.run_hook_exec_panic(&panic_payload); - Err(ProgramExecuteError::Panic(panic_payload)) - } - } } /// Run the command line program |
