diff options
| author | Ram Rachum <ram@rachum.com> | 2020-07-27 14:42:52 +0300 |
|---|---|---|
| committer | Ram Rachum <ram@rachum.com> | 2020-07-27 14:42:52 +0300 |
| commit | 2b68a6056f4ae406eed09729a778c9f1b651317e (patch) | |
| tree | d42215d8395c80766d0d3e7db51091614b191b7b /sounddevice.py | |
| parent | afe0a822b5591c2e3ae7fe9f1517d7342e048c46 (diff) | |
Fix exception causes all over the codebase
Diffstat (limited to 'sounddevice.py')
| -rw-r--r-- | sounddevice.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sounddevice.py b/sounddevice.py index 26b3625..f547f2f 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -2341,9 +2341,9 @@ class CoreAudioSettings(object): try: self._flags = conversion_dict[conversion_quality.lower()] - except (KeyError, AttributeError): + except (KeyError, AttributeError) as e: raise ValueError('conversion_quality must be one of ' + - repr(list(conversion_dict))) + repr(list(conversion_dict))) from e if change_device_parameters: self._flags |= _lib.paMacCoreChangeDeviceParameters if fail_if_conversion_required: @@ -2421,9 +2421,9 @@ class _CallbackContext(object): try: import numpy assert numpy # avoid "imported but unused" message (W0611) - except ImportError: + except ImportError as e: raise ImportError( - 'NumPy must be installed for play()/rec()/playrec()') + 'NumPy must be installed for play()/rec()/playrec()') from e self.loop = loop self.event = threading.Event() self.status = CallbackFlags() @@ -2627,8 +2627,8 @@ def _get_stream_parameters(kind, device, channels, dtype, latency, pass # NumPy not available or invalid dtype (e.g. 'int24') or ... try: sampleformat = _sampleformats[dtype] - except KeyError: - raise ValueError('Invalid ' + kind + ' sample format') + except KeyError as e: + raise ValueError('Invalid ' + kind + ' sample format') from e samplesize = _check(_lib.Pa_GetSampleSize(sampleformat)) if latency in ('low', 'high'): latency = info['default_' + latency + '_' + kind + '_latency'] @@ -2679,8 +2679,8 @@ def _split(value): invalue, outvalue = value except TypeError: invalue = outvalue = value - except ValueError: - raise ValueError('Only single values and pairs are allowed') + except ValueError as e: + raise ValueError('Only single values and pairs are allowed') from e return invalue, outvalue |
