[fpc-pascal] CGI, Handle Exceptions

Michael Van Canneyt michael at freepascal.org
Wed Jul 20 17:40:34 CEST 2016



On Wed, 20 Jul 2016, Marcos Douglas wrote:

> 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.

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.



More information about the fpc-pascal mailing list