[Vala] Can I use the symbolic name of the code of errors in code



Hi,

Say I have the program at the bottom of this mail and in the catch
clause I want to know the error that was thrown was from the FAILED or
the SYNTAX code. How can I check this. I can obtain the error code by
e.code but how do I compare it with FAILED or SYNTAX

I'd like to write something like:

if (e.code == MyError.FAILED) {

}


Jaap


-------

using GLib;

public class Sample : GLib.Object{

        public void foo () throws MyError {
                throw new MyError.FAILED ("Hello");
        }

        static int main (string[] args) {
                var x = new Sample ();
                try {
                        x.foo ();
                } catch (MyError e) {
                        stdout.printf ("%d, %s", e.code, e.message);
                }
                return 0;
        }
}

public errordomain MyError {
        FAILED,
        SYNTAX  
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]