CodeIgniter Forums
Exception handling - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Exception handling (/thread-10374.html)



Exception handling - El Forum - 07-29-2008

[eluser]movmer[/eluser]
How do I setup Exception handling in CI?

For instance: If I get a unique key violation exception, I want to send the message back to the view that the user was working on instead of a different error page. How do I do that?

Code:
MyModel extends Model{

function register() {
  try {
  }
  catch(Exception $e)
    // Here I wamt to catch log the message and send it back to the controller or view?
  }

}

Thanks
Movmer


Exception handling - El Forum - 07-29-2008

[eluser]Michael Wales[/eluser]
I usually use flashdata and a redirect to the same controller (which would then echo out that flashdata variable).