Hi,
Is possible to get all exceptions in one place, in a CGI/FastCGI programs?
I need to know the Request instance too, to treat the exception properly.
Regards,
Marcos Douglas

Mailing lists / fpc-pascal / 2016-07
5 messages · 3 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi,
Is possible to get all exceptions in one place, in a CGI/FastCGI programs?
I need to know the Request instance too, to treat the exception properly.
Regards,
Marcos Douglas
No, you cannot.
You can override Application.ShowException, but then you do not know the current request.
What I do is make a descendent of TFPWebModule which overrides "HandleRequest', and which handles exceptions in a generic way. It returns JSON when the request expects JSON etc.
All my other modules are descendent of this descendent.
Michael.
On Wed, Jul 20, 2016 at 12:40 PM, Michael Van Canneyt <
Hmm, could be a solution. Thank you.
Marcos Douglas
No, you cannot. You can override Application.ShowException, but then you do not know the…
I need to know the Request instance too, to treat the exception properly.
As Michael has pointed out, the current design has no access to the TRequest instance. My alternative solution would be to create descendant Exception class that has Request property. For every exception you raise deliberately, use this class. But you know this is limited to such an exception only...
You can override Application.ShowException, but then you do not know the current request.
What was the idea behind OnShowRequestException only gets TResponse instead of along with TRequest?
But some exceptions I don't have control (exceptions, of course). I will always need the context to any exception. So, Michael tip is simple to implement to have full control of exceptions.
Regards,
Marcos Douglas