[Vala] Construct exceptions from numeric error codes
- From: Sandino Flores Moreno <tigrux gmail com>
- To: vala-list gnome org
- Subject: [Vala] Construct exceptions from numeric error codes
- Date: Thu, 11 Feb 2010 12:49:32 -0600
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]