Am Donnerstag, den 11.02.2010, 21:46 +0100 schrieb Julian Andres Klode:
> Am Donnerstag, den 11.02.2010, 12:49 -0600 schrieb Sandino Flores
> Moreno:
> > Hello.
> > 
> > Is there a way to construct a throwable error instance from an error code?
> > 
> > I want to implement something like this:
> > 
> >   void try_run(int err_code) throws GLib.Error {
> >       if (err_code != 0)
> >           throw new GLib.Error (Quark.from_string ("My Error"),
> > err_code, err_desc (err_code));
> >   }
> 
> Try to assign the error to a variable and you get:
> 
> a.vala:3.18-3.81: error: Assignment: Cannot convert from `GLib.Error' to
> `GLib.Error'
>            Error e = new Error (Quark.from_string ("My Error"),
> err_code, "TEST");
> 
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> So I think there is a bug in Vala.
> 
It actually works if you cast it but it looks stupid, i.e.

 throw (Error)new Error (Quark.from_string ("My Error"), err_code, "T");

works.
-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.


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

Reply via email to