Re: error code from delete or beforeDelete?

2012-05-30 Thread Steve Found
If you reply to this email, your message will be added to the discussion below: http://cakephp.1045679.n5.nabble.com/error-code-from-delete-or-beforeDelete-tp5708340p5708378.html To start a new topic under CakePHP, email [hidden email] /user/SendEmail.jtp?type=nodenode=5708382i=0

Re: error code from delete or beforeDelete?

2012-05-30 Thread Steve Found
If you reply to this email, your message will be added to the discussion below: http://cakephp.1045679.n5.nabble.com/error-code-from-delete-or-beforeDelete-tp5708340p5708378.html To start a new topic under CakePHP, email

Re: error code from delete or beforeDelete?

2012-05-30 Thread AD7six
On Wednesday, 30 May 2012 13:00:47 UTC+2, Ratty wrote: Thanks for this thread actually Bill, it has given me a lot of pause for thought... Exceptions are a method of reporting WHAT has gone wrong or is about to go wrong. It is not a method of reporting WHERE it went wrong. In my

Re: error code from delete or beforeDelete?

2012-05-30 Thread bs28723
For more options, visit this group at http://groups.google.com/group/cake-php If you reply to this email, your message will be added to the discussion below: http://cakephp.1045679.n5.nabble.com/error-code-from-delete

Re: error code from delete or beforeDelete?

2012-05-30 Thread Steve Found
It's far easier to test since all the logic is in the model and a model test case can exercise all the different scenarios in one hit. The test with exceptions would need to be something like... function testCategoryNotEmptyDeletion { ... setup illegal data to throw the right exception but

Re: error code from delete or beforeDelete?

2012-05-30 Thread AD7six
On Wednesday, 30 May 2012 15:00:08 UTC+2, Ratty wrote: It's far easier to test since all the logic is in the model and a model test case can exercise all the different scenarios in one hit. The test with exceptions would need to be something like... function

Re: error code from delete or beforeDelete?

2012-05-30 Thread stork
In your example the Category model delete function should not be called unless that category is empty Exactly. There should not be any delete this category links rendered in views, if category is not empty, or - they have to be disabled - this is work for views/helpers. But: - this is

Re: error code from delete or beforeDelete?

2012-05-30 Thread Steve Found
On 30/05/12 14:54, AD7six wrote: a model test case can exercise all the different scenarios in one hit A test method should test one thing only, writing multiple scenarios in one test method is in and of itself a bad habit (of which I'm guilty of doing in the past). Using exceptions or

Re: error code from delete or beforeDelete?

2012-05-29 Thread stork
I need to do more reading on Exceptions, but my case seems more like a flash message than throwing an exception. If you have your own custom exception NotEmptyCategoryException, you can throw it from beforeDelete() and catch it in controller: try { $this-Category-delete($id); } catch

Re: error code from delete or beforeDelete?

2012-05-29 Thread stork
...or even better: try { if ($this-Category-delete($id)) { $this-Session-setFlash('Category has been deleted'); $this-redirect(array('action' = 'index')); } else { $this-Session-setFlash('Unknown error'); } } catch (NotEmptyCategoryException $e) {

Re: error code from delete or beforeDelete?

2012-05-29 Thread Steve Found
On 29/05/12 15:35, stork wrote: ...or even better: try { if ($this-Category-delete($id)) { $this-Session-setFlash('Category has been deleted'); $this-redirect(array('action' = 'index')); } else { $this-Session-setFlash('Unknown error'); } } catch

Re: error code from delete or beforeDelete?

2012-05-29 Thread stork
I need to do more reading on Exceptions, but my case seems more like a flash message than throwing an exception. Go back to reading ;-) because it is easier to throw 2 different custom exceptions NotEmptyCategoryException (has some products) and NotLeafCategoryException (has some

Re: error code from delete or beforeDelete?

2012-05-29 Thread bs28723
/error-code-from-delete-or-beforeDelete-tp5708340p5708378.html To start a new topic under CakePHP, email ml-node+s1045679n125572...@n5.nabble.com To unsubscribe from CakePHP, click here http://cakephp.1045679.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=1255722code

Re: error code from delete or beforeDelete?

2012-05-29 Thread stork
Can either of you, give me some best practices for exceptions processing? Maybe it is my self-taught PHP CakePHP experiences but I have not a done a lot with exceptions. Is this efficient? Any good references to do some reading on this? Learn from the best ones ;-)

error code from delete or beforeDelete?

2012-05-28 Thread bs28723
This has got to be a newbie question. I have searched, but can't seem to find an answer. Is there a way to get an error code for why the delete or beforeDelete failed and have this passed back to the Controller instead of just false? using

Re: error code from delete or beforeDelete?

2012-05-28 Thread Steve Found
searched, but can't seem to find an answer. Is there a way to get an error code for why the delete or beforeDelete failed and have this passed back to the Controller instead of just false? using the example from the documentation 1. |function beforeDelete()| 2. |{| 3. |$count = $this-Product

Re: error code from delete or beforeDelete?

2012-05-28 Thread stork
Throw OutOfBoundsException somewhere and catch it from outside, or create your own exception http://book.cakephp.org/2.0/en/development/exceptions.html#creating-your-own-application-exceptions Also, read better beforeDelete() callback for your example: public function beforeDelete($cascade =

Re: error code from delete or beforeDelete?

2012-05-28 Thread bs28723
://groups.google.com/group/cake-php If you reply to this email, your message will be added to the discussion below: http://cakephp.1045679.n5.nabble.com/error-code-from-delete-or-beforeDelete-tp5708340p5708348.html To start a new

Error Code

2010-02-20 Thread dido
table thead thISBN/ththTitle/ththAuthor/th /thead ?php foreach($books as $book): ? tr td?php echo $book['Book']['isbn'] ?/td td?php echo $book['Book']['title'] ?/td td?php echo $book['Book']['penerbit'] ?/td /tr ?php endforeach; ?

Re: Error Code

2010-02-20 Thread Jeremy Burns
It looks as if you haven't set the $books array in your controller. Jeremy Burns jeremybu...@me.com On 20 Feb 2010, at 09:45, dido wrote: table thead thISBN/ththTitle/ththAuthor/th /thead ?php foreach($books as $book): ? tr td?php echo