Added a few exceptions that will be thrown at the time of errors. Makes for easier debugging. Also updated README accordingly

This commit is contained in:
Rob Gloudemans
2013-07-27 17:46:57 +02:00
parent 042ab7a45a
commit 628244bdcf
8 changed files with 103 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ Now all you have to do is add the service provider of the package and alias the
Add a new line to the `service providers` array:
'\Gloudemans\Shoppingcart\ShoppingcartServiceProvider'
'Gloudemans\Shoppingcart\ShoppingcartServiceProvider'
And finally add a new line to the `aliases` array:
@@ -221,6 +221,18 @@ N.B. Keep in mind that the cart stays in the last set instance for as long as yo
N.B.2 The default cart instance is called `main`, so when you're not using instances,`Cart::content();` is the same as `Cart::instance('main')->content()`.
## Exceptions
The Cart package will throw exceptions if something goes wrong. This way it's easier to debug your code using the Cart package or to handle the error based on the type of exceptions. The Cart packages can throw the following exceptions:
| Exception | Reason |
| ------------------------------------- | ------------------------------------------------------------------------ |
| *ShoppingcartInstanceException* | When no instance is passed to the instance() method |
| *ShoppingcartInvalidItemException* | When a new product misses one of it's arguments (id, name, qty, price) |
| *ShoppingcartInvalidPriceException* | When a not numeric price is passed |
| *ShoppingcartInvalidQtyException* | When a not numeric quantity is passed |
| *ShoppingcartInvalidRowIDException* | When the rowId that got passed doesn't exists in the current cart |
## Example
Below is a little example of how to list the cart content in a table: