I forgot to mention, this is the error I'm getting:

error: `GLib.Error' is not an error type
throw new GLib.Error(error_domain(), err, err.to_string());
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


On Thu, Feb 11, 2010 at 12:49 PM, Sandino Flores Moreno
<[email protected]> wrote:
> 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));
>  }
>
> It would be invoked as follows:
>
>  try {
>    try_run ( one_command ());
>    try_run ( another_command ());
>    ...
>  }
>  except (Error e) {
>   ...
>  }
>
> This is because I'm wrapping an non-glib API that reports its errors
> using return values,
> and I want to construct GLib Exceptions from those values.
>
> However, Vala does not allow me to launch plain GLib.Error instances.
>
> How to work around it?
>
> Thanks.
>
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to