@@ -141,7 +141,7 @@ def __init__(self, name, use_exact_name=False, no_start_server=False,
141141 self ._status = Status (status [0 ])
142142 if not self ._ptr :
143143 raise JackError ('Error initializing "{0}": {1}' .format (
144- name , self .status ))
144+ name , self .status ), errno = status [ 0 ] )
145145
146146 self ._inports = Ports (self , _AUDIO , _lib .JackPortIsInput )
147147 self ._outports = Ports (self , _AUDIO , _lib .JackPortIsOutput )
@@ -411,7 +411,8 @@ def connect(self, source, destination):
411411 destination .encode ())
412412 if err == _errno .EEXIST :
413413 raise JackError ('Connection {0!r} -> {1!r} '
414- 'already exists' .format (source , destination ))
414+ 'already exists' .format (source , destination ),
415+ errno = err )
415416 _check (err ,
416417 'Error connecting {0!r} -> {1!r}' .format (source , destination ))
417418
@@ -2642,7 +2643,18 @@ def __repr__(self):
26422643class JackError (Exception ):
26432644 """Exception for all kinds of JACK-related errors."""
26442645
2645- pass
2646+ def __init__ (self , msg , errno = None ):
2647+ """Initialize new exception instance.
2648+
2649+ Parameters
2650+ ----------
2651+ errno : int, optional
2652+ The error or status code returned by the JACK library function,
2653+ which resulted in this exception being raised. Defaults to `None`.
2654+
2655+ """
2656+ super ().__init__ (msg )
2657+ self .errno = errno
26462658
26472659
26482660class CallbackExit (Exception ):
@@ -2915,4 +2927,4 @@ def callback_wrapper(msg):
29152927def _check (error_code , msg ):
29162928 """Check error code and raise JackError if non-zero."""
29172929 if error_code :
2918- raise JackError ('{0} ({1})' .format (msg , error_code ))
2930+ raise JackError ('{0} ({1})' .format (msg , error_code ), errno = error_code )
0 commit comments