Re: [Libxmlplusplus-general] Exceptions / Abort parsing



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Vendredi 29 Novembre 2002 22:24, Murray Cumming wrote:
> On Fri, 2002-11-29 at 21:15, christian altfrau de wrote:
> > Hi!
> >
> > I tryed to throw an exception in a SaxParser::on_* function, but the
> > program dies (receiving SIGABRT) instead of catching it. Isn't this
> > possible because of libxml? And is there another way to stop parsing
> > within these callback functions?
>
> I have been thinking about this too. The exception isn't caught because
> a C++ exception can't survive if thrown inside a function called from C.
> You can catch exceptions inside the callback, but you can't catch
> exceptions thrown _by_ a callback.

What we can do about this is to create an exception type which user exceptions 
would have to herit from. In the static callback methods of SaxParser we just 
have to catch it, store it in the class, and cancel the parse. In the parse_* 
methods, if we 'see' that there is an exception, just throw it again using a 
virtual Raise method that the user exception would have to implement.

I'll try to implement this this week...

Cheers,

Christophe
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE96i/5B+sU3TyOQjARAugtAJ44+5rUUMl1Tc5DfjWOUeZKZF61kgCgzKYT
n5piK+d+IzjGssp2OluhslA=
=gHsp
-----END PGP SIGNATURE-----





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