登录后如何重新引发Delphi异常?
发布时间:2020-12-15 10:17:03 所属栏目:大数据 来源:网络整理
导读:你知道一种在Delphi代码中捕获,记录和重新引发异常的方法吗? 一个简单的例子: procedure TForm3.Button1Click(Sender: TObject);begin try raise Exception.Create('Bum'); except on E: Exception do begin MyHandleException(E); end; end;end;procedur
你知道一种在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; 所以我需要重新提出它在除了块,但我想知道是否有一个更好的方法来编写我自己的方法来处理和(在特定条件)重新提出异常。 解决方法
如果要在某些条件下重新提出异常,请写
procedure TForm3.Button1Click(Sender: TObject); begin try raise Exception.Create('Bum'); except on E: Exception do begin if MyHandleException(E) then raise; end; end; end; function TForm3.MyHandleException(AException: Exception): boolean; begin ShowMessage(AException.Message); result := true/false; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |