]> git.sesse.net Git - vlc/commitdiff
python-ctypes: tweak exception handling
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Thu, 3 Sep 2009 07:57:03 +0000 (09:57 +0200)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Thu, 3 Sep 2009 08:53:08 +0000 (10:53 +0200)
bindings/python-ctypes/header.py

index 83b370f84c30d02a60cd0c9a09b486289e1310c5..cfe047b0e9375c5e2ff58402c02b1855ade12a18 100755 (executable)
@@ -33,6 +33,7 @@ create a libvlc Instance. From this instance, you can then create
 L{MediaPlayer} and L{MediaListPlayer} instances.
 """
 
+import logging
 import ctypes
 import sys
 
@@ -224,10 +225,13 @@ def check_vlc_exception(result, func, args):
     """Error checking method for functions using an exception in/out parameter.
     """
     ex=args[-1]
+    if not isinstance(ex, (VLCException, MediaControlException)):
+        logging.warn("python-vlc: error when processing function %s. Please report this as a bug to vlc-devel@videolan.org" % str(func))
+        return result
     # Take into account both VLCException and MediacontrolException:
     c=getattr(ex, 'raised', getattr(ex, 'code', 0))
     if c:
-        raise LibVLCException(args[-1].message)
+        raise LibVLCException(ex.message)
     return result
 
 ### End of header.py ###