首页 > 代码库 > Delphi之Raise抛出异常

Delphi之Raise抛出异常

技术分享

 

相关资料:

http://blog.csdn.net/a20071426/article/details/10160171

 

实例代码:

 1 unit Unit1; 2  3 interface 4  5 uses 6   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7   Dialogs, StdCtrls; 8  9 type10   TForm1 = class(TForm)11     Button1: TButton;12     procedure Button1Click(Sender: TObject);13   private14     { Private declarations }15   public16     { Public declarations }17   end;18 19 var20   Form1: TForm1;21 22 implementation23 24 {$R *.dfm}25 26 procedure TForm1.Button1Click(Sender: TObject);27 var28   int1: Integer;29 begin30   try31     int1 := StrToInt(A);32   except33     raise Exception.CreateFmt(%d = %s,[1001, 您的程序在Unit1单元32行出错了!]);34   end;35 end;36 37 end.

 

Delphi之Raise抛出异常