Exception handling

This commit is contained in:
Balthasar Reuter
2015-07-01 00:05:02 +02:00
parent 7e947f3492
commit 928ba63bd1

View File

@@ -146,11 +146,14 @@ class Photobooth:
event = self.display.wait_for_event() event = self.display.wait_for_event()
self.handle_event(event) self.handle_event(event)
# Catch exceptions and display message
except CameraException as e: except CameraException as e:
self.handle_exception(e.message) self.handle_exception(e.message)
except Exception as e: # Do not catch KeyboardInterrupt and SystemExit
print("SERIOUS ERROR!") except (KeyboardInterrupt, SystemExit):
self.handle_exception(e.message) raise
except:
self.handle_exception("SERIOUS ERROR!")
def handle_gpio(self, channel): def handle_gpio(self, channel):
if channel in [ self.trigger_channel, self.shutdown_channel ]: if channel in [ self.trigger_channel, self.shutdown_channel ]:
@@ -317,7 +320,7 @@ class Photobooth:
self.display.clear() self.display.clear()
self.display.show_message(e.message) self.display.show_message(e.message)
self.display.apply() self.display.apply()
sleep(1) sleep(2)
else: else:
raise CameraException("Giving up! Please start again!", False) raise CameraException("Giving up! Please start again!", False)
else: else: