From: John Ralls [mailto:[EMAIL PROTECTED]
> Looks to me like Paul (Marquess, the author of the DbXml perl wrappers)
> is catching the C++ exceptions and wrapping them in a perl object, then
> using croak to signal the exception to perl. That's why you get a
> blessed reference that looks like a C++ exception.
Got it in one.
I did consider using the Error module. One of the reasons I didn't use it
was it didn't provide an interface I could use in XSUB land (the C wrapper
layer between Perl and the DbXml library) and I didn't fancy writing one at
the time. There was probably something else that put me off using Error, but
right now I can't remember what that is. I still have an item in my todo
list to look at Error, so it will get investigated.
> Rather than modifying AxKit's Error.pm handler, perhaps you could wrap
> your DbXml calls in your own try (or eval) block, decode what you get
> into an Error.pm object, and then re-throw it to AxKit.
That's probably the best approach to take.
> Oh, and a caution about UNIVERSAL::isa(): It can only be called by a
> blessed reference and will panic (ie, even an eval won't keep the
> program going) if you try to call it with an unblessed variable. If
> you're not absolutely sure that what you're getting is blessed, it's
> better to use something like "if( ref $foo && ref $foo == 'bar')".
> Unfortunately, while perl's C API has a function for detecting the
> blessedness of a variable, it isn't (AFAIK) exposed to perl code
> (though I suppose one could write a simple xs to do so).
>
> Regards,
> John Ralls
>
> On May 8, 2005, at 12:20 PM, Mike Trotman wrote:
>
> > I'm using Sleepycat DbXml (2.1.7) with AxKit.
> >
> > This is a question about mixing non-Error.pm exception objects with
> > Error.pm exceptions.
> >
> > This is not an urgent question - as I can currently identify the error
> > messages using a quick hack (see below)
> > but I would like to know if there is a cleaner way to do this (in
> > either package)
> > or an idea of the work involved.
> >
> >
> > I've written an AxContentProvider to retrieve documents from Sleepycat
> > containers.
> > All works fine - as long as there are no errors.
> >
> > However I think Sleepycat uses it's own XMLException class and
> > Carp::croak for all it's errors(?)
> > rather than Error.pm - which is what AxKit uses(?).
> >
> > So I'm getting error messages about unknown 'throws in Axkit - rather
> > than the Sleepycat error message.
> >
> > It looks like the AxKit $SIG{__DIE__} handler is assuming all errors
> > are either AxKit / Error.pm Exceptions or simple strings.
> >
> > It looks like I can achieve the error reporting I need in the short
> > term by one simple hack in Axkit's prep_exception
> >
> > sub prep_exception {
> > my $err = shift;
> >
> > if (ref($err) =~ /std::exception|XmlException/i) {
> > return Apache::AxKit::Exception::Error->new(-text =>
> > $err->what());
> > }
> > elsif (ref($err)) {
> > return $err;
> > }
> > elsif ($err) {
> > return Apache::AxKit::Exception::Error->new(-text => $err);
> > }
> > else {
> > return;
> > }
> > }
> >
> > Is this all I would need to do to deal with non-AxKit errors in AxKit?
> > (and would using UNIVERSAL::isa($err, 'Error' be a correct and better
> > way to trap Error.pm errors?)
> >
> > Is this all I would need to do to catch DbXML errors (i.e. would they
> > all be XmlExceptions or std::exception)?
> >
> > Does anyone using AxKit or DbXml have any experience of another
> > 'clean' way to do this?
> > (My experience with error handling is limited to my own code.)
> >
> > Has anyone replaced DbXml's XmlException handling with an Error.pm
> > wrapper?
> > (or have any suggestions about how to do this?)
> >
> > Any help appreciated.
> >
> >
> > Mike
> >
> >
> >
> > --
> > No virus found in this outgoing message.
> > Checked by AVG Anti-Virus.
> > Version: 7.0.308 / Virus Database: 266.11.6 - Release Date: 06/05/2005
> >
> >
> >
> > ------------------------------------------
> > To remove yourself from this list, send an
> > email to [EMAIL PROTECTED]
> >
>
>
>
> ------------------------------------------
> To remove yourself from this list, send an
> email to [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]