Re: [Vala] How to ignore exceptions?



My 2 pennies:

What about adding a code attribute like [IgnoreException] ? that would perform better than trycatching

It seems the most logical option to me. Vala is a language that allows
ignoring exceptions, and (as far as I remember, it was a while ago when
I was writing my vala code) it generates code printing warning about
uncaught exception each time the exception is thrown, but not caught. I
guess that we should have two solutions (not one or the other, but both
implemented):
- command line switch like -Wno-exceptions - it would disable all
  warnings about uncaught exceptions at the compile time, and in the
  non-debug builds it would also cause not generating code for printing
  exception information if the exception is thrown;
- and some code attribute, that could be used in code, if the author is
  100% sure that in this particular case exception will never be
  thrown, or that it can be ignored (compile and run time behaviour the
  same as above).

Both these features have the advantage that no syntax changes in the
language are needed.

best regards,

On 31/10/2011, at 10:06, Xavier Bestel <xavier bestel free fr> wrote:

On Sun, 2011-10-30 at 11:04 -0400, Sam Wilson wrote:
Perhaps a better way to do this is like this:

string[] test = new string[3];
for (int i = 0; i < 3; i++)
{
    try
    {
        test[i] = kf.get_string(group, key);
    }
    catch (KeyFile.Error error)
    {
        // Do nothing
    }
}
if (!test[0] && !test[1] && !test[3]) return false;

What do you think?

Won't that interrupt the execution flow, i.e. if the first
g_key_file_get_string() throws an exception, the other ones won't be
executed ?

   Xav

_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list

_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list


-- 
Mój klucz publiczny o identyfikatorze 1024D/E12C5A4C znajduje się na
serwerze hkp://keys.gnupg.net

My public key with signature 1024D/E12C5A4C is on the server
hkp://keys.gnupg.net

Attachment: signature.asc
Description: PGP signature



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