Hello World!

I'm working with some data objects that throw Exception::Class::DBI if, for 
some reason, the database doesn't what you expect. Well, yeah, I did write 
these data objects myself, and Exception::Class::DBI seemed right since they 
are intended for the use of DBI, I (think I) know I could in principle let 
the DBI throw an Apache::AxKit::Exception, but for various reasons... well, 
lets just say for the sake of the argument, that a Exception::Class::DBI has 
been thrown by a module I can't modify, and I want to get some more sensible 
things in the error logs than "unknown exception"... 

I'm not quite used to working with exceptions yet, but I realize the great 
value compared to other types of error handling, so I'd really like to use 
them. 

So, what I figured is that I'll just catch the exception, and then throw a 
Apache::AxKit::Exception::IO instead, with the error string from the 
Exception::Class::DBI as -text. This would be the standard way to do it, and 
for now, I can't think of a situation where I would like to do it 
differently, and since I'm Lazy, I therefore would like to write that code 
only once. I have a bunch of Taglibs and Providers, and they inherit stuff 
from things higher in the hierarchy. So I guess I could implement the catch 
there. But I after having thought about it for some time, I couldn't imagine 
any way to do it...

So, instead, I started playing with a situation where I have a known bug that 
causes the database to fail and throw a Exception::Class::DBI::STH. Still, in 
this situation, I did not find a way to accomplish what I wanted. 

The error happens under some circumstances when my Taglib instructs the object 
to save itself (i.e. INSERT itself into the database table). So, I thought 
I'd just put the catch immediately after the save, like this:
    $story->save();
    catch Exception::Class::DBI with {
        my $ex = shift;
        throw Apache::AxKit::Exception::IO(
                                           -text => $ex->error
                                           );
        }

What happens here is that an exception is thrown in the save(), and I was 
hoping to catch it immediately afterwards. 

But apparently, that's not how it works, this is how the error log looks:
 [Fri Jan 23 23:05:02 2004] [warn] [client 127.0.0.1] [AxKit] Caught an 
exception
Use of uninitialized value in subroutine entry at 
/usr/local/lib/perl/5.6.1/AxKit.pm line 332.
[Fri Jan 23 23:05:02 2004] [error] Unknown exception, type: 
Exception::Class::DBI::STH at /usr/local/lib/perl/5.6.1/AxKit.pm line 391.

So, I'm wondering, how should I go about to do this Right?


Cheers,

Kjetil


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to