Delphi之Exception获得错误信息

Posted 疯狂delphi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Delphi之Exception获得错误信息相关的知识,希望对你有一定的参考价值。

 

相关资料:

http://www.cnblogs.com/hackpig/archive/2010/02/15/1668547.html

 

实例代码:

 1 unit Unit1;
 2 
 3 interface
 4 
 5 uses
 6   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 7   Dialogs, StdCtrls;
 8 
 9 type
10   TForm1 = class(TForm)
11     Button1: TButton;
12     procedure Button1Click(Sender: TObject);
13   private
14     { Private declarations }
15   public
16     { Public declarations }
17   end;
18 
19 var
20   Form1: TForm1;
21 
22 implementation
23 
24 {$R *.dfm}
25 
26 procedure TForm1.Button1Click(Sender: TObject);
27 var
28   int1: Integer;
29 begin
30   try
31     int1 := StrToInt(\'A\');
32   except
33     ShowMessage(Exception(ExceptObject).Message);
34   end;
35 end;
36 
37 end.

 

PS:

try
DataModule1.PHBADOQuery2.ExecSQL ;
except
on e:exception do
begin
ShowMessage(e.Message);
end;
end;

try
int1 := StrToInt(\'A\');
except
ShowMessage(Exception(ExceptObject).Message);
end;

try
except
end;

try
finally
end;

 

以上是关于Delphi之Exception获得错误信息的主要内容,如果未能解决你的问题,请参考以下文章

Delphi 获得Webbrowser弹出对话框的信息

delphi高手突破之异常及错误处理

delphi程序突然出现 Exception EAccessViolation错误

mysql 错 Could not open JDBC Connection for transaction; nested exception is java.sql.SQLExceptio(代码片

使用 Delphi 检索 ADO 错误

springboot报错说 Failed to parse multipart servlet request; nested exception is java.io.IOException(代码片