Welcome Guest, Not a member yet? Register   Sign In
How to load a view for the error page?
#23

[eluser]Aquillyne[/eluser]
I've managed to get it working. You extend the Exceptions class as follows:

MY_Exceptions

Code:
class MY_Exceptions extends CI_Exceptions {

    var $CI;
    
    function MY_Exceptions()
    {
        parent::CI_Exceptions();
        $this->CI =& get_instance();
    }

    function _redirect($error)
    {
        $err = $this->CI->session->flashdata("error");
        if ($err != FALSE)
        die("<h1>Fatal Error</h1>" . $err['message']);
        
        $this->CI->session->set_flashdata("error", $error);
        redirect("error");
    }

    function show_error($heading = "Fatal Error", $message = "Unknown Error")
    {
        $error = array(
            "heading"    => $heading,
            "message"    => $message
        );
        $this->_redirect($error);
    }
    
    function show_php_error($severity, $message, $filepath, $line)
    {
        $heading = "Error ($severity)";
        $message = $message . " in file " . $filepath . " on Line " . $line . ".";
        $this->show_error($heading, $message);
    }
    
}

Then you just need an error controller ("error"), which captures the session flashdata, and feeds it into an error view.

Note that I've got the sessions class set to autoload in my autoload.php config file.


Messages In This Thread
How to load a view for the error page? - by El Forum - 06-07-2008, 08:57 PM
How to load a view for the error page? - by El Forum - 06-08-2008, 04:07 AM
How to load a view for the error page? - by El Forum - 06-08-2008, 07:04 AM
How to load a view for the error page? - by El Forum - 06-08-2008, 07:43 AM
How to load a view for the error page? - by El Forum - 06-08-2008, 11:28 AM
How to load a view for the error page? - by El Forum - 06-08-2008, 12:18 PM
How to load a view for the error page? - by El Forum - 06-08-2008, 12:21 PM
How to load a view for the error page? - by El Forum - 07-19-2008, 12:32 PM
How to load a view for the error page? - by El Forum - 07-19-2008, 01:48 PM
How to load a view for the error page? - by El Forum - 07-19-2008, 03:04 PM
How to load a view for the error page? - by El Forum - 07-19-2008, 03:25 PM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:16 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:23 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:28 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:30 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:31 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:33 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:42 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:44 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 10:58 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 11:09 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 11:12 AM
How to load a view for the error page? - by El Forum - 07-20-2008, 12:21 PM
How to load a view for the error page? - by El Forum - 07-20-2008, 01:11 PM
How to load a view for the error page? - by El Forum - 07-20-2008, 01:15 PM
How to load a view for the error page? - by El Forum - 07-20-2008, 05:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB