IntraWeb Archive

New ServerController.OnLogException event

New ServerController.OnLogException event

There is a new event in TIWServerController named OnLogException

This event may be used to do custom logging and/or notification when an exception occurs inside an IntraWeb application.

    property OnLogException: TOnLogExceptionEvent read mOnLogException write mOnLogException;

where

    TOnLogExceptionEvent = function(const ReportInfo: TStrings): Boolean of Object;

This event fires only when an exception is raised. In this case, the IWExceptionLogger first generates all report information (in a TStringList). If this event handler is assigned it is then called, protected by a TCriticalSection (meaning that OnLogException event handler IS thread safe – but also means that the code inside this event handler blocks other threads generating other exceptions).

IntraWeb developers may use this event to save the error report to a database, upload it to some FTP server, send it via email, among many other possibilities.

The result of this event handler indicates if the logging was handled by the user: If the result is TRUE, IWExceptionLogger will NOT save the error log file (or save it to the event viewer). If the method returns FALSE, then IWExceptionLogger will do its normal processing.

When using this event, have in mind two important things:

  • This is thread safe. Only one thread (in case of IntraWeb applications, one session) can run this code at a time. So make it FAST. Do not write lengthy procedures there!
  • This event will be triggered only if IWExceptionLogger is enabled