More robust call to addAddressType.
This is not strictly necessary, but it seems right to me that we trap the error and rollback ourselves here as well.
This commit is contained in:
parent
6e57396399
commit
e3cf1665d9
1 changed files with 11 additions and 3 deletions
|
@ -196,13 +196,21 @@ sub addEmailAddress($$$$) {
|
||||||
|
|
||||||
die "addEmailAddress: invalid id, $id" unless $self->_verifyId($id);
|
die "addEmailAddress: invalid id, $id" unless $self->_verifyId($id);
|
||||||
|
|
||||||
die "addEmailAddress:: invalid email address, $emailAddressType"
|
die "addEmailAddress: invalid email address, $emailAddressType"
|
||||||
unless defined $emailAddressType and Mail::RFC822::Address::valid($emailAddress);
|
unless defined $emailAddressType and Mail::RFC822::Address::valid($emailAddress);
|
||||||
|
|
||||||
$self->_beginWork();
|
$self->_beginWork();
|
||||||
|
|
||||||
my $addressTypeId = $self->addAddressType($emailAddressType);
|
my $addressTypeId;
|
||||||
|
eval {
|
||||||
|
$addressTypeId = $self->addAddressType($emailAddressType);
|
||||||
|
};
|
||||||
|
if ($@ or not defined $addressTypeId) {
|
||||||
|
my $err = $@;
|
||||||
|
$err = "addEmailAddress: unable to addAddressType" if (not defined $err);
|
||||||
|
$self->_rollback();
|
||||||
|
die $@ if $@;
|
||||||
|
}
|
||||||
my $sth = $self->dbh->prepare("INSERT INTO email_address(email_address, type_id, date_encountered)" .
|
my $sth = $self->dbh->prepare("INSERT INTO email_address(email_address, type_id, date_encountered)" .
|
||||||
"VALUES( ?, ?, date('now'))");
|
"VALUES( ?, ?, date('now'))");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue