Capturar errores en producción


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. try
  2. {
  3. // Attempt to execute the response
  4. $request->execute();
  5. }
  6. catch (Exception $e)
  7. {
  8. if ( ! IN_PRODUCTION)
  9. {
  10. // Just re-throw the exception
  11. throw $e;
  12. }
  13. try
  14. {
  15. // Log the error
  16. Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e));
  17.  
  18. // Create a 404 response
  19. $request->status = 404;
  20. $request->response = View::factory('template')
  21. ->set('title', '404')
  22. ->set('content', View::factory('errors/404'));
  23. }
  24. catch (Exception $e)
  25. {
  26. echo "Something terrible happened. We will look into it!";
  27. Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e));
  28. }
  29. }

URL: http://forum.kohanaframework.org/comments.php?DiscussionID=5016&page=1#Item_0

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.