• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redirect to user defined view page if any type of error occurs

I was able to redirect only database type error using hooks concept but does not work for general all type of error.

using below code i was able to redirect db related error. and error_get_last() always return null only

class PHPFatalError {

    public function setHandler() {
//        print_r(error_get_last()); //always returns null
        register_shutdown_function([$this, 'handleShutdown']);

    function handleShutdown() {
        $CI =& get_instance();
        $has_error $CI->db->error();

    if ($has_error['message'] != '') {




PHP handles most of the general errors.

CI handles them by using a custom Exception Error Handler, you may need to extend it to
work the way you want.

It's located in ./system/core/Exceptions.php

If you extend it place it in ./application/core/MY_Exceptions.php
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.