Browse Source

Log and print error for all examples

Michal Podhradsky 6 years ago
parent
commit
4c7606d9c3
3 changed files with 20 additions and 3 deletions
  1. 7 1
      examples/benchmark.rs
  2. 6 1
      examples/httpclient.rs
  3. 7 1
      examples/ping.rs

+ 7 - 1
examples/benchmark.rs

@@ -108,7 +108,13 @@ fn main() {
     let mut processed = 0;
     while !CLIENT_DONE.load(Ordering::SeqCst) {
         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);
+            }
+        }
+
 
         // tcp:1234: emit data
         {

+ 6 - 1
examples/httpclient.rs

@@ -66,7 +66,12 @@ fn main() {
 
     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);

+ 7 - 1
examples/ping.rs

@@ -121,7 +121,13 @@ fn main() {
     let ident = 0x22b;
 
     loop {
-        iface.poll(&mut sockets, Instant::now()).unwrap();
+        let timestamp = Instant::now();
+        match iface.poll(&mut sockets, timestamp) {
+            Ok(_) => {},
+            Err(e) => {
+                debug!("poll error: {}",e);
+            }
+        }
 
         {
             let timestamp = Instant::now();