Paul Marquess wrote:
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.
OK - that's what I assumed.
And thanks Paul for the example Perl scripts - they enabled me to start using DbXml within one hour of successfully building it.
I am using the DbXml module with Axkit and Apache.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.
The thing that confused me was that all my DbXml blocks are done using eval.
But if I look at the $@ that comes out of this - it is an AxKit Error reference.
AxKit is catching the error in a handler - and then wrapping it in an AxKit object.
And this is where I'm getting the 'unknown throw' error - which is why I hacked it in AxKit.
Would I be able to use a local $SIG{__DIE__} in my code to catch the error before Apache / AxKit
and do the necessary conversion?
(That's what I'm trying next.)
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).
Thanks John - I will test for a ref() 1st and then check what sort of ref. I'm planning something like
if (ref($@)) {
if (UNIVERSAL::isa($@,'Error') {
return $@;
}
elsif (UNIVERSAL::isa($@,'XmlException')) {
return Apache::AxKit::Exception->new(-text=>'[EMAIL PROTECTED]>what()');
}
elsif (UNIVERSAL::isa($@,;std::exception')) {
return Apache::AxKit::Exception->new(-text=>'[EMAIL PROTECTED]>what()');
}
else {
return Apache::AxKit::Exception->new(-text=>'Unknown Exception :'.ref($@)); }
else {
return Apache::AxKit::Exception->new(-text=>'$@');
}
Regards, John Ralls
-- 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 unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
