How should I re-raise a Delphi exception after logging it?
Posted
by Nik
on Stack Overflow
See other posts from Stack Overflow
or by Nik
Published on 2010-05-27T17:08:55Z
Indexed on
2010/05/28
6:01 UTC
Read the original article
Hit count: 264
delphi
|exception-handling
Do you know a way to trap, log, and re-raise exception in Delphi code? A simple example:
procedure TForm3.Button1Click(Sender: TObject);
begin
try
raise Exception.Create('Bum');
except
on E: Exception do
begin
MyHandleException(E);
end;
end;
end;
procedure TForm3.MyHandleException(AException: Exception);
begin
ShowMessage(AException.Message);
LogThis(AException.Message);
// raise AException; - this will access violate
end;
So I need to re-raise it in the except block but I was wondering if there is a better way to write my own method to handle and (on specific conditions) to re-raise exceptions.
© Stack Overflow or respective owner