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 ([EMAIL PROTECTED])           http://www.josef-k.net/
Physics Particle Theory (student)   http://www.pact.cpes.sussex.ac.uk/
================ An eclectic mix of fact and theory. =================

Attachment: pgptmgRTpyAE1.pgp
Description: PGP signature

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to