F
fanwendou
Unregistered / Unconfirmed
GUEST, unregistred user!
对异常处理请问各位大虾,有什么高的见解.
下面的一段异常处理我还有不解处请指教
implementation
type
ME =class(Exception)
//写入错误信息到文件
procedure WriteErrtoFile(const FileName:string);
end;
{$R *.dfm}
//实现写入文件操作
procedure me.WriteErrtoFile(const FileName:string);
var
f:TextFile;
begin
AssignFile(f,FileName) ;
Append(f);
Writeln(f,message);
CloseFile(f);
end;
procedure someoperation;
var
x,y:Integer;
myErr:ME;
begin
x:=1;
y:=0;
if x>y then
begin
myErr:=me.create('发生ME类型的错'+#13#10+'错误的位置在TForm1.someoperation'
+'已经写入日志') ;
myErr.WriteErrtoFile('E:/Err.txt');
raise myErr;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
try
someoperation;
except
on E:medo
begin
MessageDlg(e.Message,mtError,[mbOK],0);
end;
end;
end;
在"on E:medo
"这个地方怎么理解?
下面的一段异常处理我还有不解处请指教
implementation
type
ME =class(Exception)
//写入错误信息到文件
procedure WriteErrtoFile(const FileName:string);
end;
{$R *.dfm}
//实现写入文件操作
procedure me.WriteErrtoFile(const FileName:string);
var
f:TextFile;
begin
AssignFile(f,FileName) ;
Append(f);
Writeln(f,message);
CloseFile(f);
end;
procedure someoperation;
var
x,y:Integer;
myErr:ME;
begin
x:=1;
y:=0;
if x>y then
begin
myErr:=me.create('发生ME类型的错'+#13#10+'错误的位置在TForm1.someoperation'
+'已经写入日志') ;
myErr.WriteErrtoFile('E:/Err.txt');
raise myErr;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
try
someoperation;
except
on E:medo
begin
MessageDlg(e.Message,mtError,[mbOK],0);
end;
end;
end;
在"on E:medo
"这个地方怎么理解?