]> git.lizzy.rs Git - rust.git/commitdiff
Bubble up error
authorEdwin Cheng <edwin0cheng@gmail.com>
Thu, 23 Apr 2020 17:38:58 +0000 (01:38 +0800)
committerEdwin Cheng <edwin0cheng@gmail.com>
Thu, 23 Apr 2020 17:38:58 +0000 (01:38 +0800)
crates/ra_proc_macro_srv/src/cli.rs
crates/rust-analyzer/src/bin/main.rs

index c7f41e4485f34c78a89218215fa68b91cd0536a2..ded1bcdbcb11c9e3d7107597a22ee5099e3db74b 100644 (file)
@@ -4,16 +4,13 @@
 use ra_proc_macro::msg::{self, Message};
 use std::io;
 
-pub fn run() {
+pub fn run() -> io::Result<()> {
     loop {
-        let req = match read_request() {
-            Err(err) => {
-                // Panic here, as the stdin pipe may be closed.
-                // Otherwise, client will be restarted the service anyway.
-                panic!("Read message error on ra_proc_macro_srv: {}", err);
-            }
-            Ok(None) => continue,
-            Ok(Some(req)) => req,
+        // bubble up the error for read request,
+        // as the stdin pipe may be closed.
+        let req = match read_request()? {
+            None => continue,
+            Some(req) => req,
         };
 
         let res = match req {
index e8d5dad6577c84945fe01043cbf859167e564403..22a84b50c0998a3b2b461ebb0077be54e01a250a 100644 (file)
@@ -66,7 +66,7 @@ fn setup_logging() -> Result<()> {
 }
 
 fn run_proc_macro_srv() -> Result<()> {
-    ra_proc_macro_srv::cli::run();
+    ra_proc_macro_srv::cli::run()?;
     Ok(())
 }