Bläddra i källkod

fix: panic on top-level errors

Yujia Qiao 4 år sedan
förälder
incheckning
30ac69fdb1
2 ändrade filer med 9 tillägg och 5 borttagningar
  1. 4 1
      Cargo.toml
  2. 5 4
      src/lib.rs

+ 4 - 1
Cargo.toml

@@ -28,7 +28,11 @@ hot-reload = ["notify"]
 console = ["console-subscriber", "tokio/tracing"]
 console = ["console-subscriber", "tokio/tracing"]
 
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+[profile.dev]
+panic = "abort"
+
 [profile.release]
 [profile.release]
+panic = "abort"
 lto = true
 lto = true
 
 
 [profile.bench]
 [profile.bench]
@@ -39,7 +43,6 @@ inherits = "release"
 opt-level = "z"
 opt-level = "z"
 lto = true
 lto = true
 codegen-units = 1
 codegen-units = 1
-panic = "abort"
 
 
 [dependencies]
 [dependencies]
 tokio = { version = "1", features = ["full"] }
 tokio = { version = "1", features = ["full"] }

+ 5 - 4
src/lib.rs

@@ -84,7 +84,7 @@ pub async fn run(args: Cli, shutdown_rx: broadcast::Receiver<bool>) -> Result<()
                 if let Some((i, _)) = last_instance {
                 if let Some((i, _)) = last_instance {
                     info!("General configuration change detected. Restarting...");
                     info!("General configuration change detected. Restarting...");
                     shutdown_tx.send(true)?;
                     shutdown_tx.send(true)?;
-                    i.await??;
+                    i.await?;
                 }
                 }
 
 
                 debug!("{:?}", config);
                 debug!("{:?}", config);
@@ -120,8 +120,8 @@ async fn run_instance(
     args: Cli,
     args: Cli,
     shutdown_rx: broadcast::Receiver<bool>,
     shutdown_rx: broadcast::Receiver<bool>,
     service_update: mpsc::Receiver<ServiceChange>,
     service_update: mpsc::Receiver<ServiceChange>,
-) -> Result<()> {
-    match determine_run_mode(&config, &args) {
+) {
+    let ret: Result<()> = match determine_run_mode(&config, &args) {
         RunMode::Undetermine => panic!("Cannot determine running as a server or a client"),
         RunMode::Undetermine => panic!("Cannot determine running as a server or a client"),
         RunMode::Client => {
         RunMode::Client => {
             #[cfg(not(feature = "client"))]
             #[cfg(not(feature = "client"))]
@@ -135,7 +135,8 @@ async fn run_instance(
             #[cfg(feature = "server")]
             #[cfg(feature = "server")]
             run_server(&config, shutdown_rx, service_update).await
             run_server(&config, shutdown_rx, service_update).await
         }
         }
-    }
+    };
+    ret.unwrap();
 }
 }
 
 
 #[derive(PartialEq, Eq, Debug)]
 #[derive(PartialEq, Eq, Debug)]