Hi DBIC gurus!
I tried to throw typed exceptions from exception_action based on DBD
error codes. And to no avail.
Here are problems that I've faced:
1. There are very little docs and few tests on exception_action.
2. exception_action is being called twice ( at least more than once )
for every RDBMS error.
This is demonstrated here http://paste.scsys.co.uk/194724 Note that
$DBI::state and $DBI::err are set only the first time call
3. $DBI::state and $DBI::err are not always set to actual RDBMS error
codes during exception_action call. $DBI::err is set to default
2000000000 in the following case with populate for instance:
http://paste.scsys.co.uk/194725
BTW, I've noticed strange warning for the case when exception_action is
in use and populate() call initiates DB error:
>>A DBIx::Class::Storage::TxnScopeGuard went out of scope without
explicit commit or error. Rolling back. at ...
What I basically want to do is:
MySchema->execption_action( sub {
my $e = shift;
if ( is_canstraint_fail() ) {
UniqueConstraintFail->throw( "$e" );
} else {
GeneralException->throw( "$e" );
}
});
And later:
eval {
$schema->resultset( 'user' )->create({ user fileds go here });
};
if ( UniqueConstraintFail->caught ) {
UserExists->throw
} elsif ....
What are your suggestions to solve this? What are bugs and what are not?
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]