Selaa lähdekoodia

examples: remove the remaining panics on poll error.

whitequark 6 vuotta sitten
vanhempi
commit
185a0ca781
4 muutettua tiedostoa jossa 14 lisäystä ja 4 poistoa
  1. 6 1
      examples/client.rs
  2. 6 1
      examples/loopback.rs
  3. 1 1
      examples/ping.rs
  4. 1 1
      examples/server.rs

+ 6 - 1
examples/client.rs

@@ -61,7 +61,12 @@ fn main() {
     let mut tcp_active = false;
     loop {
         let timestamp = Instant::now();
-        iface.poll(&mut sockets, timestamp).expect("poll error");
+        match iface.poll(&mut sockets, timestamp) {
+            Ok(_) => {},
+            Err(e) => {
+                debug!("poll error: {}", e);
+            }
+        }
 
         {
             let mut socket = sockets.get::<TcpSocket>(tcp_handle);

+ 6 - 1
examples/loopback.rs

@@ -127,7 +127,12 @@ fn main() {
     let mut did_connect = false;
     let mut done = false;
     while !done && clock.elapsed() < Instant::from_millis(10_000) {
-        iface.poll(&mut socket_set, clock.elapsed()).expect("poll error");
+        match iface.poll(&mut socket_set, clock.elapsed()) {
+            Ok(_) => {},
+            Err(e) => {
+                debug!("poll error: {}", e);
+            }
+        }
 
         {
             let mut socket = socket_set.get::<TcpSocket>(server_handle);

+ 1 - 1
examples/ping.rs

@@ -125,7 +125,7 @@ fn main() {
         match iface.poll(&mut sockets, timestamp) {
             Ok(_) => {},
             Err(e) => {
-                debug!("poll error: {}",e);
+                debug!("poll error: {}", e);
             }
         }
 

+ 1 - 1
examples/server.rs

@@ -77,7 +77,7 @@ fn main() {
         match iface.poll(&mut sockets, timestamp) {
             Ok(_) => {},
             Err(e) => {
-                debug!("poll error: {}",e);
+                debug!("poll error: {}", e);
             }
         }