Skip to content

Commit 9ff74fd

Browse files
committed
添加第三方库panic处理
1 parent ff56fd1 commit 9ff74fd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

dsserver/src/server.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,18 @@ pub fn run(port: u16, pwd: String) {
8282
}
8383
let ss = stream.try_clone().unwrap();
8484
let th1 = std::thread::spawn(move || {
85-
screen_stream(ss);
85+
if let Err(e) = std::panic::catch_unwind(||{
86+
screen_stream(ss);
87+
}) {
88+
eprintln!("{:?}", e);
89+
}
8690
});
8791
let th2 = std::thread::spawn(move || {
88-
event(stream);
92+
if let Err(e) = std::panic::catch_unwind(||{
93+
event(stream);
94+
}) {
95+
eprintln!("{:?}", e);
96+
}
8997
});
9098
th1.join().unwrap();
9199
th2.join().unwrap();

0 commit comments

Comments
 (0)