Documente Academic
Documente Profesional
Documente Cultură
procedure CallAProcedure;
begin
try
CallRaiseAnException;
except
on E: Exception do
GlobalExceptionHandler(E, 'UnitName', Application.ExeName, 'CallAProcedure
');
end;
end;
procedure CallRaiseAnException;
begin
try
RaiseAnException;
except
on E: Exception do
GlobalExceptionHandler(E, 'UnitName', Application.ExeName,
'CallRaiseAnException');
end;
end;
procedure RaiseAnException;
begin
try
raise Exception.Create('This is the original error message');
except
on E: Exception do
GlobalExceptionHandler(E, 'UnitName', Application.ExeName,
'CallRaiseAnException');
end;
end;
Now in the above case when the exception object reaches the Application's
OnException method, the information of procedures that it will contain will be:
Button1Click
CallAProcedure
CallRaiseAnException
RaiseAnException.
Please let me know your opinions and views regarding the same
Sri Ram Ambuga Nandakumar
********************************************************************************
**
Hi Sriram
I have implemented the code from your article "Exception Handling in Delphi - Fr
amework to log the complete traverse information", but for some reason when I ru
n it (using your example) I don't get the Button1Click (in other words the initi
al method called to start the process) when I loop through the CallStack informa
tion. Here is th code that I am using:
function GetCallStackDetails(AException : Exception) : string;
var
recErrDet : TErrorDetails;
iCount : integer;
begin
Result := '';
for iCount := 0 to (AException as ECustomException).StackLength-1 do
begin
recErrDet := (AException as ECustomException).ErrorDetails[iCount];
Result := Result + recErrDet.sProcedure end;
end;
Respond
RE: Missing item on Call Stack
Derek Gibb (May 5 2006 2:58PM)
Hi Sriram
I have found what the problem was. You need to change the GetStackLength to the
following:
function ECustomException.GetStackLength: integer;
begin
Result := High(FCallStack)+1;
end;
Note the "+1". I am not sure why this is the case, but it appears to work now s
o I am not complaining.
Cheers
Derek
Respond
RE: RE: Missing item on Call Stack
Sriram Ambuga (May 5 2006 3:38PM)
Hello Derek,
Yes there is a problem in the code that is posted.
In the 'GetErrorDetails' method it should be (Index <= StackLength) instead of
Index < StackLength.
HTH.
Respond
RE: Missing item on Call Stack
Sriram Ambuga (May 5 2006 3:43PM)
Your solution works too.
Respond
RE: RE: Missing item on Call Stack
Derek Gibb (May 5 2006 6:25PM)
Thanks Sriram!
It is working perfectly now. I will try your solution when I get to work on Mon
day!
Cheers
Derek
Respond