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;

http://www.cnblogs.com/FKdelphi/p/6281559.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM