[Catalyst] Handling Exceptions

Kiefer, Sascha sk at intertivity.com
Sun Apr 16 18:40:16 CEST 2006


First, see what i have:

package MyApp::Model::DBIC::User;

use strict;
use warnings;
use base 'DBIx::Class::Core';

__PACKAGE__->has_one ( profile  => 'MyApp::Model::DBIC::UserProfile',
'userId' );
__PACKAGE__->has_one ( settings => 'MyApp::Model::DBIC::UserSettings',
'userId' );

Now i create a user:

my $user = $c->model('DBIC::User')->create(
		username => $username,
		password => $csh->generate,
my $profile  = $user->create_related( 'profile',  { email => $emailaddr, }
my $settings = $user->create_related( 'settings', { registerDate =>
DateTime->now } );

This is all good, but let's say createing the settings does not work/fails
for some reason.
I get a exception. But then i would like to rollback the creating of the
user and ist profile.
What's the best practice for that?


More information about the Catalyst mailing list