CI_Exceptions::show_exception PHP Method

show_exception() public method

--------------------------------------------------------------------
public show_exception ( $exception )
    public function show_exception($exception)
    {
        $templates_path = config_item('error_views_path');
        if (empty($templates_path)) {
            $templates_path = VIEWPATH . 'errors' . DIRECTORY_SEPARATOR;
        }
        $message = $exception->getMessage();
        if (empty($message)) {
            $message = '(null)';
        }
        if (is_cli()) {
            $templates_path .= 'cli' . DIRECTORY_SEPARATOR;
        } else {
            set_status_header(500);
            $templates_path .= 'html' . DIRECTORY_SEPARATOR;
        }
        if (ob_get_level() > $this->ob_level + 1) {
            ob_end_flush();
        }
        ob_start();
        include $templates_path . 'error_exception.php';
        $buffer = ob_get_contents();
        ob_end_clean();
        echo $buffer;
    }

Usage Example

 function show_exception($exception)
 {
     if (!is_null($CI =& get_instance())) {
         $message = $exception->getMessage();
         if (empty($message)) {
             $message = '(null)';
         }
         $error_data['exception'] = $exception;
         $error_data['message'] = $message;
         $CI->load->helper('email');
         report_error('error_exception', $error_data);
     }
     return parent::show_exception($exception);
 }