mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-10 10:52:49 +02:00
catch panics at base functions to integrate with other fatal errors.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
89a3c80700
commit
08a2fecc0e
3 changed files with 26 additions and 11 deletions
|
@ -6,10 +6,11 @@ mod serve;
|
|||
|
||||
extern crate conduit_core as conduit;
|
||||
|
||||
use std::{future::Future, pin::Pin, sync::Arc};
|
||||
use std::{panic::AssertUnwindSafe, pin::Pin, sync::Arc};
|
||||
|
||||
use conduit::{Result, Server};
|
||||
use conduit::{Error, Result, Server};
|
||||
use conduit_service::Services;
|
||||
use futures::{Future, FutureExt, TryFutureExt};
|
||||
|
||||
conduit::mod_ctor! {}
|
||||
conduit::mod_dtor! {}
|
||||
|
@ -17,15 +18,27 @@ conduit::rustc_flags_capture! {}
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "Rust" fn start(server: &Arc<Server>) -> Pin<Box<dyn Future<Output = Result<Arc<Services>>> + Send>> {
|
||||
Box::pin(run::start(server.clone()))
|
||||
AssertUnwindSafe(run::start(server.clone()))
|
||||
.catch_unwind()
|
||||
.map_err(Error::from_panic)
|
||||
.unwrap_or_else(Err)
|
||||
.boxed()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "Rust" fn stop(services: Arc<Services>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
|
||||
Box::pin(run::stop(services))
|
||||
AssertUnwindSafe(run::stop(services))
|
||||
.catch_unwind()
|
||||
.map_err(Error::from_panic)
|
||||
.unwrap_or_else(Err)
|
||||
.boxed()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "Rust" fn run(services: &Arc<Services>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
|
||||
Box::pin(run::run(services.clone()))
|
||||
AssertUnwindSafe(run::run(services.clone()))
|
||||
.catch_unwind()
|
||||
.map_err(Error::from_panic)
|
||||
.unwrap_or_else(Err)
|
||||
.boxed()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue