先申明,我不是 DELPHI 的三星,达到3星后各个板块的级别都一样的。在 DELPHI 里面我只是个新手,只学了DELPHI 8天,希望大家帮忙try ... excetpt on e:Exception do 中的 E 是哪里来的?凭空出来的?怎么没在帮助里面找到说明?E是继承某个类么?这里只有 E.MESSAGE,难道没有错误号么?
我如何根据 E 的类型获取了某个类型错误后继续判定错误号?毕竟一种类型中有很多个错误了,我需要针对不同的错误返回给客户不同的消息。
我如何根据 E 的类型获取了某个类型错误后继续判定错误号?毕竟一种类型中有很多个错误了,我需要针对不同的错误返回给客户不同的消息。
解决方案 »
- 超怪问题
- 打包问题!!!!!急!!!!!救命!!!!在线等
- 怎么读写扇区?
- dbgrid中的问题
- 有哪位高手有国际数据加密(IDEA)算法的pascal源代码,本人将以300分相送
- delphi 用IWebbrowser2如何获取IE地址栏的网址?
- 如何判 webbrowser.navigate('http://www.AAAAA.com') 已更新完毕,?,待更新完毕后执行其他代码语句webbrowser.navigate('http://www.A
- Delphi中的事件问题...
- 有没有ASCALL码控件
- 谁能给我一个好的答复?(http://www.csdn.net/expert/topic/169/169121.shtm)
- 在使用IdTCPServer、IdTCPClient编程时,服务器端如何及时监测到客户端已意外断掉
- 小师妹,进来接分。。。
觉得没什么好解析的
呵呵,又或者是我不懂吧_____________________
http://lysoft.7u7.net
就好像 var I: integer; 一样,声明一个变量而已你当然可以 on abc: exception 也可,目的是声明一个 exception 变量
比较严谨的写法,应该是:try
{ calculation statements }
except
on EZeroDivide do ...
on EIntOverflow do ...
on EIntUnderflow do ...
end;细化出错的类型,然后,根据不同的错误,再做不同的处理或提示,
但通常,我们为了方便,就直接用其基类,Exception 这样,就可捕获到所有的错误(其实不是所有).但我看过许多人的代码,包括我自己,一般都是用
try ... excetpt on e:Exception do
这个定式而已,
如需要,就直接 ShowMessage(E.message) 告诉用户出错的信息如果你的一个function 或 procedure 里面有多个步骤,那一般我会分开...
try ... excetpt on e:Exception do
begin
dosomeing;
exit;
end;...
try ... excetpt on e:Exception do
begin
dosomeing;
exit;
end;
...这样分开不同步骤的可能错误,我觉得,看你在编写什么类型的程序,如果是类库,一般只是直接 raise 出去, 如果是界面,一般是自己定义的,如“无法连接到数据库, ...”, “无法打开文件,请查询...", 给用户太精确的出错信息也没意义
=========================================
Try...except statementsTopic groups See also....An exception handler can specify an identifier before the name of the exception class. This declares the identifier to represent the exception object during execution of the statement that follows on...do. The scope of the identifier is limited to that statement. For example,try ...
except
on E: Exception do ErrorDialog(E.Message, E.HelpContext);
end;
try
...
except
ShowMessage(Exception(ExceptObject).Message);
end;