Re: Error Handling in 1.2?
On Wed, Dec 17, 2008 at 2:10 PM, Rob Wilkerson wrote: > Would you mind expanding on that just a bit? How would I look at the > error data? In my case, I'd like to echo back an error message. What > structure do I look at to do so? I may have spoken a little too soon. This code still returns the success message, but the code below is failing on a foreign key issue (a separate question about that to follow). Even though it's failing, the success block is being executed. What am I missing? if ( $this->CommercialVendor->saveAll ( $this->data ) ) { echo 'success'; } else { header ( 'HTTP/1.0 500 Internal Server Error', true, '500' ); echo 'Error'; } -- Rob Wilkerson http://robwilkerson.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Error Handling in 1.2?
On Wed, Dec 17, 2008 at 1:48 PM, Rob wrote: > > All you need to do is check that you got something back from the > saveAll, so you wrap it like: > > if ($this->User->saveAll($this->data)){ > -- success > } > else { > -- failure > } > > Then you can look at the error data in the failure section ... Would you mind expanding on that just a bit? How would I look at the error data? In my case, I'd like to echo back an error message. What structure do I look at to do so? Thanks. -- Rob Wilkerson http://robwilkerson.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Error Handling in 1.2?
All you need to do is check that you got something back from the saveAll, so you wrap it like: if ($this->User->saveAll($this->data)){ -- success } else { -- failure } Then you can look at the error data in the failure section ... On Dec 17, 10:16 am, Rob Wilkerson wrote: > Today, I wrote my first code to saveAll() from form input and, knowing > I probably didn't do it right the first time, I wrapped my save > attempt in a try/catch block. Imagine my surprise when everything > returned success messages, but nothing actually got saved. A look at > the source indicated that exceptions aren't being thrown which I > assume is due to PHP4.x compatibility issues. > > Since I can't use try/catch, what's the "cake way" to catch > exceptions? I see the "Error Handling" section in the docs, but do I > really need to write a custom error handler just to determine that an > error occurred? I see how to "throw" an error using $this->cakeError > (), but it seems like there has to be some built-in capability to > catch them; I'm just not seeing it. > > Thanks. > > Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Error Handling in 1.2?
Today, I wrote my first code to saveAll() from form input and, knowing I probably didn't do it right the first time, I wrapped my save attempt in a try/catch block. Imagine my surprise when everything returned success messages, but nothing actually got saved. A look at the source indicated that exceptions aren't being thrown which I assume is due to PHP4.x compatibility issues. Since I can't use try/catch, what's the "cake way" to catch exceptions? I see the "Error Handling" section in the docs, but do I really need to write a custom error handler just to determine that an error occurred? I see how to "throw" an error using $this->cakeError (), but it seems like there has to be some built-in capability to catch them; I'm just not seeing it. Thanks. Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---