CodeIgniter Forums
Controllers to handle errors - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Controllers to handle errors (/showthread.php?tid=8692)



Controllers to handle errors - El Forum - 05-27-2008

[eluser]Unknown[/eluser]
Would it be possible to handle errors (404, database) with a controller easily (I did find something by searching this forum, but it seemed to be a flawed implementation), or at least use CI functions in the error pages CI uses by default?


Controllers to handle errors - El Forum - 05-28-2008

[eluser]Chris Newton[/eluser]
In your HTACCESS file, add:

Code:
ErrorDocument 404 /yourcontroller/your_error_function

Database errors should probably be written to a log, rather than displayed for security purposes.


Controllers to handle errors - El Forum - 07-16-2008

[eluser]Unknown[/eluser]
Hi. Sorry to bump this.

I've built a controller to act as a 404 page. I currently have modified the exception library to send a redirection header to the controller, but there *must* be a better way to do this. For example, currently it goes like this: the page that the user requested returns 302 found instead of 404 (the actual 404 controller returns a 404 header, though).

I've went through pretty much every topic concerning this and I haven't found a good way to do it. How much would it take to modify the exception library to call a controller instead?