1 unit LCLExceptionStackTrace; 2 3 {$mode objfpc}{$H+} 4 5 interface 6 7 uses 8 SysUtils, LazLoggerBase, Forms; 9 10 implementation 11 12 type 13 TEventContainer = class 14 public 15 procedure HandleApplicationException(Sender: TObject; E: Exception); 16 end; 17 18 { TEventContainer } 19 20 procedure TEventContainer.HandleApplicationException(Sender: TObject; 21 E: Exception); 22 begin 23 if not (E is EAbort) then 24 begin 25 DebugLn('TApplication.HandleException: ',E.ClassName); 26 DebugLn(E.Message); 27 DumpExceptionBackTrace; 28 Application.ShowException(E); 29 end; 30 end; 31 32 procedure HandleOnShowException(Msg: ShortString); 33 begin 34 DebugLn('TApplication.HandleException: Strange Exception'); 35 DebugLn(Msg); 36 DumpExceptionBackTrace; 37 end; 38 39 initialization 40 SysUtils.OnShowException := @HandleOnShowException; 41 Application.OnException := @TEventContainer(nil).HandleApplicationException; 42 43 end. 44 45