CodeIgniter Forums
Custom 500 error page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Custom 500 error page (/showthread.php?tid=81235)



Custom 500 error page - sjender - 02-08-2022

Another day, another question  Big Grin.

I have my own custom 404 page set with: 
PHP Code:
$routes->set404Override('App\Controllers\Errors::show404'); 

However, now I want to do the same with the 500 (Whoops we seem to have hit a snag) error.
I don't want to edit the default file, I need to have it pointed to 'App\Controllers\Errors:: show500'.
Can someone point me in the right direction?


RE: Custom 500 error page - iRedds - 02-08-2022

Just override Services::exceptions() to return your class that extends CodeIgniter\Debug\Exceptions.
It's simple ))))))


RE: Custom 500 error page - sjender - 02-08-2022

Wel,, that's in the system folder right?
I prefer not to edit stuff there.
I would like not to edit this every time I update CI.
Isn't there a way outside the system folder?


RE: Custom 500 error page - iRedds - 02-08-2022

Extending CodeIgniter » Creating Core System Classes


RE: Custom 500 error page - sjender - 02-08-2022

Sorry,

I've never done this before.
But are you saying I should overide the entire Exceptions class?
The only method that I seem to need to edit is determineView().

How is this done?


RE: Custom 500 error page - iRedds - 02-08-2022

I don't know what you want.
You said you don't want to change the default file.
Therefore, I would venture to suggest that you want to change some kind of logic.
Here is a class with logic for you)


RE: Custom 500 error page - kenjis - 02-08-2022

Why don't you create app/Views/errors/html/error_500.php ?


RE: Custom 500 error page - sjender - 02-09-2022

Because I would like to have different views depending on various situations.

Therefore I need to be able to change determination of the view file.
Just like I did with the 404 file