Re: [Vala] Construct exceptions from numeric error codes
- From: Sandino Flores Moreno <tigrux gmail com>
- To: vala-list gnome org
- Subject: Re: [Vala] Construct exceptions from numeric error codes
- Date: Thu, 11 Feb 2010 14:43:22 -0600
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
<tigrux gmail com> 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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]