[Vala] Error codes as values?



Given that many C libraries return integer error codes, is there a way
to pass the return value into a "throw new". How would I set up the
errordomain in the vapi file so the enumeration codes match?

Prefer this (doesn't actually work):

code = Database.open(filename, out _db);
if ( code != OK ) throw new WrapperError ( code, "Could not open database" );

intstead of this:

switch ( code ) {
    case A: throw new WrapperError.A ( "foo" ); break;
    case B: throw new WrapperError.B ( "bar" ); break;
}


-Sam



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