[Vala] Introspection for exception instances
- From: Michael Gratton <mike vee net>
- To: Vala <vala-list gnome org>
- Subject: [Vala] Introspection for exception instances
- Date: Tue, 14 Nov 2017 01:23:50 +1100
Hey all,
I'm looking into improving Geary's error reporting at the moment, and
would like to be able to reconstruct the domain and code names that
were given in the source file for an arbitrary error when catching it,
so that users can copy & paste some "technical details" and report it
in a bug, if they are so inclined. For example, given an instance of a
IOError.CANCELLABLE, I'd like to be able to come up with a string
representation of it as "IOError.CANCELLABLE". At the moment the best I
can get is the quark and code as strings, i.e. "g-io-error" and "32"
(or whatever).
I understand that Vala Error objects are convenience representations of
the underlying GError and not full classes, however since under the
hood a Vala errordomain generates an enum in C, I'd hope that I should
at least be able to convert the code from an int in an arbitrary error
domain back to a string, but can't work out a way to do it. Is this
possible? A nicer version of the domain value instead of the quark
string value would be great as well.
Relatedly, since the error's code is an enum, it would be handy to be
able to use it in a switch statement, e.g.:
switch (io_error.code) {
case IOError.CANCELLABLE:
...
break;
}
But again unless I am missing something, this doesn't seem to be
currently supported?
//Mike
--
⊨ Michael Gratton, Percept Wrangler.
⚙ <http://mjog.vee.net/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]