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
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
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
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
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
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
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
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
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
...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) {
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
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
/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
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 ;-)
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
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
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 =
://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
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; ?
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
20 matches
Mail list logo