[Dbix-class] Re: Catching DBI errors, without eval?
Josef Karthauser
joe at tao.org.uk
Sun Nov 12 22:31:37 GMT 2006
On Sun, Nov 12, 2006 at 11:56:58AM +0000, Josef Karthauser wrote:
> Is it possible to catch DBI errors, without having to wrap the code
> within eval blocks?
>
> The specific place where I'm experiencing trouble is,
>
> DELETE FROM contact WHERE ( contactid = ? AND owner = ? ): '1203', '7'
> DBD::mysql::st execute failed: Cannot delete or update a parent row: a
> foreign key constraint fails at
> /usr/local/lib/perl5/site_perl/5.8.8/DBIx/Class/Storage/DBI.pm line 771.
>
> which was generated from an $obj->delete call.
Answering my own question, it appears that answer is no. Looking at
_execute I see that it evokes ->throw_exception to report an error, say
when an SQL statement has failed because of a constraint.
There doesn't appear to be any facility to catch exceptions built in.
Is that correct?
What I'd like to do is call
$object->delete
and have it return a success or failure status. I'm surprised that
nobody appears to require this kind of behaviour.
Joe
--
Josef Karthauser (joe at tao.org.uk) http://www.josef-k.net/
Physics Particle Theory (student) http://www.pact.cpes.sussex.ac.uk/
================ An eclectic mix of fact and theory. =================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061112/b050df11/attachment.pgp
More information about the Dbix-class
mailing list