try except block in Delphi

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/27 17:11 UTC
Read the original article Hit count: 145

Filed under:
|

Do you guys 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);
  // raise AException; - this will access violate
end;

So I need to re-raise it in the except block but I was wondering is there a better way to write my own method to handle and (on specific conditions) to re-raise exceptions?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about exception-handling