]> git.sesse.net Git - vlc/commitdiff
Provide the exception code, handle lack of message.
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 21 Feb 2009 18:28:55 +0000 (20:28 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 21 Feb 2009 18:28:55 +0000 (20:28 +0200)
bindings/cil/src/exception.cs

index 9a9ce5a2bacfa61ec51b483157b214d562021abb..2b3118fa435a232a4de5f896d75f93374ba884f6 100644 (file)
@@ -32,6 +32,18 @@ namespace VideoLAN.LibVLC
      */
     public class VLCException : Exception
     {
+        int code;
+        /**
+         * VLC exception code.
+         */
+        public int Code
+        {
+            get
+            {
+                return code;
+            }
+        }
+
         /**
          * Creates a managed VLC exception.
          */
@@ -57,6 +69,25 @@ namespace VideoLAN.LibVLC
            : base (message, inner)
         {
         }
+
+        /**
+         * Creates a VLC exception
+         * @param code VLC exception code
+         * @param message VLC exception message
+         */
+        public VLCException (int code, string message) : base (message)
+        {
+            this.code = code;
+        }
+
+        /**
+         * Creates a VLC exception
+         * @param code VLC exception code
+         */
+        public VLCException (int code) : base ()
+        {
+            this.code = code;
+        }
     };
 
     /**
@@ -92,11 +123,16 @@ namespace VideoLAN.LibVLC
          */
         public void Raise ()
         {
+            if (raised == 0)
+                return;
+
+            string msg = U8String.FromNative (message);
             try
             {
-                string msg = U8String.FromNative (GetMessage (this));
                 if (msg != null)
-                    throw new VLCException (msg);
+                    throw new VLCException (code, msg);
+                else
+                    throw new VLCException (code);
             }
             finally
             {