From 4fb7933e34dc9cfd2c29e3ad7f9fc96c822dcde3 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 3 Jun 2010 16:11:11 -0700 Subject: [PATCH] Exception handling for getSku. --- lib/WebGUI/Shop/CartItem.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/Shop/CartItem.pm b/lib/WebGUI/Shop/CartItem.pm index 89f398ebb..cddb5b4b1 100644 --- a/lib/WebGUI/Shop/CartItem.pm +++ b/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; }