2009年5月30日

Delphi JEDI JvDebugHandler 紀錄 Exception 資訊 (full stack trace)


需先安裝 JEDI VCL for Delphi
先開啟 Map file
Project -> Options -> Linker -> Map file 選擇 Detailed 按 OK

放入元件 Jv System -> JvDebugHandler
放入元件 Memo

加入 Form1 OnCreate 事件

procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Clear;
try
Format('%s', [3]);
except

end;
end;

加入 JvDebugHandler1 OnOtherDestination 事件

procedure TForm1.JvDebugHandler1OtherDestination(Sender: TObject);
begin
Memo1.Lines.AddStrings(JvDebugHandler1.ExceptionStringList);
end;

執行程式並跳過 Exception
{ Memo
2008/3/29 下午 12:16:05 Exception EConvertError occured in ConvertErrorFmt at 0 in file
Message: Format '%s' invalid or incompatible with argument
Call stack:
[00408041] SysUtils.ConvertErrorFmt
[00409467] SysUtils.FmtStr
[00409412] SysUtils.Format
[0045EC2B] Unit1.TForm1.FormCreate (Line 32, "Unit1.pas")
[004470E1] Forms.TCustomForm.DoCreate
[00446DC1] Forms.TCustomForm.AfterConstruction
[0044E481] Forms.TApplication.CreateForm
[0045EFEF] Project1.Project1 (Line 11, "C:\Delphi7\Projects\Project1.dpr")

預設 JvDebugHandler.LogToFile = True
也會輸出 log file,預設檔名為 ${Application.Title} ERRORLOG.txt
可以直接設定 JvDebugHandler.LogFileName 來指定 log file 檔名

沒有留言:

網誌存檔