Skip to content
Permalink
Browse files

Exception handling for getSku.

  • Loading branch information...
perlDreamer committed Jun 3, 2010
1 parent 9a1c5c9 commit 4fb7933e34dc9cfd2c29e3ad7f9fc96c822dcde3
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/WebGUI/Shop/CartItem.pm
@@ -173,9 +173,10 @@ Returns an instanciated WebGUI::Asset::Sku object for this cart item.

sub getSku {
my ($self) = @_;
my $asset = '';
$asset = WebGUI::Asset->newById($self->cart->session, $self->get("assetId"));
$asset->applyOptions($self->get("options")) if $asset;
my $asset = eval { WebGUI::Asset->newById($self->cart->session, $self->get("assetId")); };
if (!Exception::Class->caught) {
$asset->applyOptions($self->get("options"));
}
return $asset;
}

@@ -229,7 +230,7 @@ Removes this item from the cart and calls $sku->onRemoveFromCart. See also delet

sub remove {
my $self = shift;
my $sku = $self->getSku;
my $sku = eval { $self->getSku; };
$sku->onRemoveFromCart($self) if $sku;
return $self->delete;
}

0 comments on commit 4fb7933

Please sign in to comment.
You can’t perform that action at this time.