From 928ba63bd19cbb70d777581044203ced199868e2 Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Wed, 1 Jul 2015 00:05:02 +0200 Subject: [PATCH] Exception handling --- photobooth.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/photobooth.py b/photobooth.py index cb0e30e..a141a97 100755 --- a/photobooth.py +++ b/photobooth.py @@ -146,11 +146,14 @@ class Photobooth: event = self.display.wait_for_event() self.handle_event(event) + # Catch exceptions and display message except CameraException as e: self.handle_exception(e.message) - except Exception as e: - print("SERIOUS ERROR!") - self.handle_exception(e.message) + # Do not catch KeyboardInterrupt and SystemExit + except (KeyboardInterrupt, SystemExit): + raise + except: + self.handle_exception("SERIOUS ERROR!") def handle_gpio(self, channel): if channel in [ self.trigger_channel, self.shutdown_channel ]: @@ -317,7 +320,7 @@ class Photobooth: self.display.clear() self.display.show_message(e.message) self.display.apply() - sleep(1) + sleep(2) else: raise CameraException("Giving up! Please start again!", False) else: