相关疑难解决方法(0)

记录后如何重新引发Delphi异常?

你知道在Delphi代码中捕获,记录和重新引发异常的方法吗?一个简单的例子:

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;
Run Code Online (Sandbox Code Playgroud)

所以我需要在except块中重新提升它,但我想知道是否有更好的方法来编写我自己的方法来处理和(在特定条件下)重新引发异常.

delphi exception-handling

25
推荐指数
3
解决办法
1万
查看次数

如何捕获后台线程中引发的未处理异常?

我有习惯执行匿名线程,如:

TThread.CreateAnonymousThread(
   procedure
   begin
     .....
   end).start;
Run Code Online (Sandbox Code Playgroud)

但问题是如果在执行过程中会出现一些未处理的异常,那么我将不会被警告!对于我们的主线程Application.OnException.我们是否有类似的背景线程?

delphi firemonkey

5
推荐指数
2
解决办法
372
查看次数

标签 统计

delphi ×2

exception-handling ×1

firemonkey ×1