From 137d0ae097ec617ba361d9498a8b1f6498964bfc Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 27 Feb 2022 17:17:23 -0500 Subject: [PATCH] Error catching for cleaning up --- sound.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sound.py b/sound.py index e0f0eb1..0b38cfc 100644 --- a/sound.py +++ b/sound.py @@ -29,16 +29,15 @@ class PCMStream: self.stream.start() def clean_up(self): - if self.stream is not None: - try: + try: + if self.stream is not None: self.stream.stop() - except Exception as e: - print(f"Error on Stop: '{e}'") - try: self.stream.close() - except Exception as e: - print(f"Error on Close: '{e}'") + + except Exception as e: + print(f"Error in clean_up: '{e}'") + class DeviceNotFoundError(Exception):