Welcome Guest, Not a member yet? Register   Sign In
Exceptions exceptions...
#1
Question 
(This post was last modified: 04-17-2020, 11:00 AM by Gary.)

Hi,

The CI framework throws a variety of exceptions… many of them are difficult (or perhaps just inconvenient) to place within a try-catch block.

Is there some easy way to be able to intercept these in a more generic way at the final output stage so that every occurrence of an exception is gracefully handled (perhaps with a generic response), even in the case of an exception being thrown somewhere where it’s not anticipated?

Some of the reason for this is that if one is using CSRF tokens that are updated on every submission, a single system-generated response will throw the server/client out of sync and break the website (or cause the client to be unnecessarily booted).

I’ve read though everything I can find in the CI user documentation on Error Handling, Using Exceptions, Custom Exceptions and Replacing Common Functions, and have even considered to use Events… as best I can tell, only way this can (sensibly) be done is by changing/extending the Core System Class:  CodeIgniter\HTTP\Response.  However, being a noob, I take note of the warning that is on ALL of the relevant documentation pages: “Messing with a core system class has a lot of implications, so make sure you know what you are doing before attempting it”

Any advice would be appreciated, thanks.

As an aside, I started off trying to configure Apache's config: with ErrorDocument 500 "Cutom 500" (as a global, then a virtual host, and also as a directory option, as well as in .htaccess)... and that seems to get totally ignored, which is why I packed up on the idea of doing it this way.
Reply


Messages In This Thread
Exceptions exceptions... - by Gary - 04-17-2020, 07:07 AM
RE: Exceptions exceptions... - by Leo - 04-19-2020, 02:08 PM
RE: Exceptions exceptions... - by Gary - 04-19-2020, 04:20 PM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 12:12 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 02:56 AM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 06:05 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 06:52 AM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 10:31 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 01:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB