program çalışırken oluşan hataları yakalayıp bunları bir txt dosyasına kaydetmek istiyorum
fakat Except olayındaki E.Message sadece olayın sonucunu veriyor
benim istediğim ise daha hatanın hangi fonksiyonda hangi satırda oluştuğu gibi detaylı bilgi almaya çalışıyorum
biraz araştırdığımda StackTrace üzerinden yapıldığını buldum fakat tam olarak nasıl işliyor bir türlü sonuçlandıramadım
bu forumdada moderatörler arasında bir yazışma olmuş fakat oradada yine yöntem anlatılmış
viewtopic.php?f=8&t=27091&p=152241&hili ... ce#p152241
Bulduğu bir örnek var fakat onuda çalıştıramadım
http://blog.gurock.com/postings/working ... trace/730/
Kod: Tümünü seç
unit UntStackTrace;
interface
uses
SysUtils, Classes, JclDebug;
implementation
function GetExceptionStackInfoProc(P: PExceptionRecord): Pointer;
var
LLines: TStringList;
LText: String;
LResult: PChar;
begin
LLines := TStringList.Create;
try
JclLastExceptStackListToStrings(LLines, True, True, True, True);
LText := LLines.Text;
LResult := StrAlloc(Length(LText));
StrCopy(LResult, PChar(LText));
Result := LResult;
finally
LLines.Free;
end;
end;
function GetStackInfoStringProc(Info: Pointer): string;
begin
Result := string(PChar(Info));
end;
procedure CleanUpStackInfoProc(Info: Pointer);
begin
StrDispose(PChar(Info));
end;
initialization
// Start the Jcl exception tracking and register our Exception
// stack trace provider.
if JclStartExceptionTracking then
begin
Exception.GetExceptionStackInfoProc := GetExceptionStackInfoProc;
Exception.GetStackInfoStringProc := GetStackInfoStringProc;
Exception.CleanUpStackInfoProc := CleanUpStackInfoProc;
end;
finalization
// Stop Jcl exception tracking and unregister our provider.
if JclExceptionTrackingActive then
begin
Exception.GetExceptionStackInfoProc := nil;
Exception.GetStackInfoStringProc := nil;
Exception.CleanUpStackInfoProc := nil;
JclStopExceptionTracking;
end;
end.
Kod: Tümünü seç
uses
…, StackTrace;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure SomeMethod;
end;
implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
try
SomeMethod;
except
// Log the exception: We use SmartInspect here because it has
// built-in support for Exception.StackTrace but you could also
// access the StackTrace property here directly.
SiMain.LogException;
end;
end;
procedure TForm1.SomeMethod;
begin
raise Exception.Create(‘A test exception’);
end;
Teşekkürler