shop_cart->update(param('sku'), param('quantity'));
my $err = shop_cart->error;
I was figuring to get back the 'Product for 2001 not found in cart.' message and act on it. However, instead I got back nothing, and my debug log had a dump listing of the shop_cart object! I spent some time digging around in this, and I hit on this which saved me from insanity:
Much to my surprise this printed out "Dancer::error". So by some bizarre quirk of inheritance, the "error" method supplied by (I think) Interchange6::Role::Errors is being replaced by Dancer::error!
The error method in Cart has now been removed. Since in schema we always throw_exception the same approach is now used in IC6::Cart and we die instead of adding errors and returning.
My code fragment looks like this:
I was figuring to get back the 'Product for 2001 not found in cart.' message and act on it. However, instead I got back nothing, and my debug log had a dump listing of the shop_cart object! I spent some time digging around in this, and I hit on this which saved me from insanity:
http://www.perlmonks.org/?node_id=413799
(That's some old, old wisdom there.)
So I added:
debug coderef2name(shop_cart->can('error'));
Much to my surprise this printed out "Dancer::error". So by some bizarre quirk of inheritance, the "error" method supplied by (I think) Interchange6::Role::Errors is being replaced by Dancer::error!