Re: [Vala] Wrapping Errors with g_prefix_error?



On Sat, 2009-08-22 at 09:24 +0200, Jan Hudec wrote:
On Thu, Aug 20, 2009 at 22:09:21 -0400, Yu Feng wrote:
GError doesn't support error wrapping as Java does. Is GLib is purposely
avoiding it?
If not, it will become a useful feature as the number of libraries that
uses GError grows, as the feature has already been proved useful in
Java, (indicated in this article):

http://tutorials.jenkov.com/java-exception-handling/exception-wrapping.html 

Actually, in my opinion that article nicely explains, why you do *not* need
to have the original error information there.

article> The main reason one would use exception wrapping is to prevent the
article> code further up the call stack from having to know about every
article> possible exception in the system.

Well, so the code further up the call stack is not going to look at the
inner exception anyway except to print it to the operator, right? But for
that, it's enough to embed the wrapped error's message into the wrapping
error message. The error code is not relevant.

I buy your point. 

In an language like Java, the error(Exception) carries more than a
message and a code. It also includes a source code reference therefore
it make sense to save the cause as an data member.

Nevertheless in the GObject case, because the error only carries an
code, and a message, there is no need to wrap the low level errors.
g_prefix_error would be sufficient as an substitute of 'wrapping'. How
can we invoke this function in vala though?

By the way, you should be suggesting things like this on the Gtk list, not
here.

I thought it was a GObject feature which was highly relevant to Vala.


Yu





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]