Skip to content

Commit 6eef105

Browse files
committed
DOC: Use the same exception handling strategy in all examples
1 parent 6e86b42 commit 6eef105

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

examples/play_file.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
status = sd.get_status()
2121
if status:
2222
logging.warning(str(status))
23-
except BaseException as e:
24-
# This avoids printing the traceback, especially if Ctrl-C is used.
25-
raise SystemExit(str(e))
23+
except KeyboardInterrupt:
24+
parser.exit('\nInterrupted by user')
25+
except Exception as e:
26+
parser.exit(type(e).__name__ + ': ' + str(e))

examples/spectrogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ def callback(indata, frames, time, status):
9494
except KeyboardInterrupt:
9595
parser.exit('Interrupted by user')
9696
except Exception as e:
97-
parser.exit(str(e))
97+
parser.exit(type(e).__name__ + ': ' + str(e))

examples/wire.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def callback(indata, outdata, frames, time, status):
3939

4040
if callback_status:
4141
logging.warning(str(callback_status))
42-
except BaseException as e:
43-
# This avoids printing the traceback, especially if Ctrl-C is used.
44-
raise SystemExit(str(e))
42+
except KeyboardInterrupt:
43+
parser.exit('\nInterrupted by user')
44+
except Exception as e:
45+
parser.exit(type(e).__name__ + ': ' + str(e))

0 commit comments

Comments
 (0)