stapix

Yet another static page generator for photo galleries

Commit
1f6923e9a5b3df957b6e32d4256e98587104e217
Parent
c9bd30f0d6faf872307738676be013fdc39a8dc4
Author
Pablo <pablo-pie@riseup.net>
Date

Improved some error handling

Added code for handling potential panicks in the rendering threads

Diffstat

1 file changed, 9 insertions, 3 deletions

Status File Name N° Changes Insertions Deletions
Modified src/main.rs 12 9 3
diff --git a/src/main.rs b/src/main.rs
@@ -131,9 +131,15 @@ fn render_gallery(pics: Vec<GalleryEntry>) -> ExitCode {
         });
     }
 
-    for msg in reciever.iter().take(pics.len()) {
-        if !msg {
-            return ExitCode::FAILURE;
+    for _ in 0..pics.len() {
+        match reciever.recv() {
+            Ok(false) => return ExitCode::FAILURE,
+            Ok(true)  => {}
+            Err(_)    => {
+                // Propagate the panic to the main thread: reciever.recv should
+                // only fail if some of the rendering threads panicked
+                panic!("rendering thread panicked!");
+            }
         }
     }