Welcome Guest, Not a member yet? Register   Sign In
Extending Exceptions redux redux redux
#1

[eluser]TheresonAntaltego[/eluser]
Greetings All!

CI newbie here. ID# 52,409, with the Local 508 CI Newbies.

I extended the show_404() function in the native exceptions class with success. Example:
Code:
class MY_Exceptions extends CI_Exceptions {

    /**
     * Constructor
     *
     */    
    function MY_Exceptions()
    {
        parent::CI_Exceptions();
    }

    // --------------------------------------------------------------------

    /**
     * 404 Page Not Found Handler
     *
     * @access    private
     * @param    string
     * @return    string
     */
    function show_404($page = '')
    {    
        $heading = '404 Page Not Found --> '.$page;
        $message = 'The page you requested was not found.';

        log_message('error', '404 Page Not Found --> '.$page);
        echo $this->show_error($heading, $message, 'error_404');
        exit;
    }
      

}
// END MY_Exceptions Class

The only change is the concatenation of the passed argument to the heading, so it is visible in the user output. Nice. But. If I try to extend the function to accept additional arguments, and display them instead of the default header and message entirely, it fails to recognize that the arguments were passed. Here is an example.:

Code:
class MY_Exceptions extends CI_Exceptions {

    /**
     * Constructor
     *
     */    
    function MY_Exceptions()
    {
        parent::CI_Exceptions();
    }

    // --------------------------------------------------------------------

    /**
     * 404 Page Not Found Handler
     *
     * @access    private
     * @param    string
     * @return    string
     */
    function show_404($page = '', $heading = '', $message = '')
    {    
        $heading = ($heading == '')
                          ?  '404 Page Not Found --> '.$page
                          :   $heading;

        $message = ($message == '')
                          ?   'The page you requested was not found.'
                          :   $message;

        log_message('error', '404 Page Not Found --> '.$page);
        echo $this->show_error($heading, $message, 'error_404');
        exit;
    }
      

}
// END MY_Exceptions Class


So I know the extension is working, just not what I figured would be basic PHP principles. Any Ideas? Forgive me if a prior Exceptions-related topic covered and answered this problem. And/or if my folly is obvious.




Theme © iAndrew 2016 - Forum software by © MyBB