Executes CipherCore code such that all the internal errors are properly formatted and logged. # Arguments `f` - closure without arguments containing CipherCore code and returning `Result<()>`
(f: T)
| 10 | /// |
| 11 | /// `f` - closure without arguments containing CipherCore code and returning `Result<()>` |
| 12 | pub fn execute_main<T, E>(f: T) |
| 13 | where |
| 14 | T: FnOnce() -> Result<(), E> + std::panic::UnwindSafe, |
| 15 | E: Display, |
| 16 | { |
| 17 | let result = std::panic::catch_unwind(|| { |
| 18 | let result = f(); |
| 19 | if let Err(e) = result { |
| 20 | error!("CipherCore Error:\n{e}"); |
| 21 | process::exit(1); |
| 22 | } |
| 23 | }); |
| 24 | process_result(result); |
| 25 | } |
| 26 | |
| 27 | #[doc(hidden)] |
| 28 | pub fn extract_panic_message(e: Box<dyn std::any::Any + Send>) -> Option<String> { |