Posted By

javierav on 08/11/10


Tagged

error production kohana


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

JSawo


Capturar errores en producción


 / Published in: PHP
 

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

  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. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: javierav on August 11, 2010

Otra versión del mismo concepto: http://github.com/vimofthevine/kyletreubig.com/blob/master/application/bootstrap.php

Posted By: javierav on August 19, 2010

Habría que detectar si el error es producto de una url incorrecta (tendríamos que lanzar un error 404 Not Found) o si es un error interno de la aplicación (cualquier otro error que no sea el 404), por lo que tendríamos que arrojar un error 503. http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40132

You need to login to post a comment.