Exceptions are programme errors, and cause the application to abort with either an Error page or an Oops page, depending on the environment the app runs in.
If you get a HttpNotFoundException in your index.php, it means your RedisException is captured and handled somewhere in your app. The standard way to handle it is to display an error from that location, either by using a custom view, or throwing one of the HttpExceptions:
try
{
.... your code
}
catch (\RedisException $e)
{
throw new \HttpServerErrorException($e->getMessage());
}
If you want a custom http exception you can capture in your index.php, you need to create an exception that extends \HttpException, and add an exception handler that returns the desired response.
I see by the way that the current index.php doesn't reflect how it is supposed to work. It should be:
// Generate the request, execute it and send the output.
try
{
// Boot the app...
require APPPATH.'bootstrap.php';
// ... and execute the main request
$response = $routerequest();
}
catch (Exception $e)
{
if (method_exists($e, 'response'))
{
$response = $e->response();
}
else
{
throw $e;
}
}
There is no need for a new route request (and loose the history and status of the original one), HttpExceptions have a response() method that already returns the correct response.
This really needs to be fixed for the next release.