I have error produced by application/views/errors/html/error_general.php
An Error Was Encountered
Unable to load the requested file: filename.php
But I want to redirect the error to my controller instead like in my error_general.php
. Can I do something like?
if(substr($message,0,36) == "Unable to load the requested file")
{
// redirect to my controller
// $this->My_controller->my_method(); -i don't know what i'm doing here, lol
}
Or is there any way to do this?
create file core/MY_Exceptions.php
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Exceptions extends Exception {
public function __construct($message, $code = 0, Exception $previous = null) {
parent::__construct($message, $code, $previous);
}
public function show_error($heading, $message, $template = 'error_general', $status_code = 500) {
// do your work here
}
}
refer codeigniter error handling guide for more help. codeigniter error handling