[xml] error-handling strategies
- From: Chris Ryland <cpr emsoftware com>
- To: XML List <xml gnome org>
- Subject: [xml] error-handling strategies
- Date: Thu, 29 May 2003 22:12:59 -0400
I'm curious about how people generally handle errors in the face of a
recursive tree-building strategy using libxml2.
In particular, out-of-memory errors vs. tree node allocation.
If you've collected a bunch of children nodes, and then, say, one of
them fails and returns a nil (due to no memory left), but you haven't
built your own parent node yet (of course, you could have allocated it
first, but let's use this as an example), what do you do? Do you have
to free all those tree fragments you've built? Seems rather messy.
Or should one always work top-down by allocating the main node you're
going to return first, connecting all the children as you go to the
main node, and, if any of them fail, just return failure as well, but
you still have a non-nil partial tree fragment to return to your
caller, who can also plug it in before returning failure to his caller,
etc.?
Ideas & sample code pointers welcome.
Cheers!
--Chris Ryland / Em Software, Inc. / www.emsoftware.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]