中间层异常传递与SafeCall调用方式的问题 (200分)

S

sotiny

Unregistered / Unconfirmed
GUEST, unregistred user!
我用MTS作为建立中间层的平台,但是异常传递却不行。我想可能是由于Safecall的问题,
他将异常封闭在函数内部,但我希望传递异常,请问如何处理?
附代码:
procedure TStudentInfoMng.UpdateStudent(const Student: IStudent);
var
StudentDB: IStudentDB;
begin
try
//创建IStudentDB对象
OleCheck(ObjectContext.CreateInstance(CLASS_StudentDB,IID_IStudentDB,StudentDB));
//调用IStudentDB中的方法,但此处Delphi修改了IStudentDB传递过来的异常。
StudentDB.UpdateStudent(Student);
except
SetAbort();
Raise;
end;
SetComplete();
end;

procedure TStudentDB.UpdateStudent(const Student: IStudent);
begin
try
spXSUpdateStudent.Parameters.ParamByName('@studentID').Value := Student.StudentID;
//设置其他参数
spXSUpdateStudent.ExecProc;
except
SetAbort();
Raise;
end;
SetComplete();
end;
TStudentDB.updateStudent执行数据库中的存储过程,执行过程中存在异常,TStudentDB.UpdateStudent
正常捕获该异常,如‘违反约束关系’等。但是,该异常却无法传递给TStudentInfoMng中的UpdateStudent函数。
在TStudentInfoMng中的UpdateStudent函数中显示为‘Ole Error 80040E2F’,请问如要获取
TStudentDB。updateStudent中的原始异常信息,应该如何做?
 
不用OLECheck 返回应该有错误信息
 
不行,Olecheck只是用于检查ObjectContext.CreateInstance(...)的执行状态。与
TStudentDB.UpdateStudent函数无关
 
此问题我已经解决了,原因是除了数据库异常外,函数中又产生了一个异常。
所以传递给上层函数的异常就是第二个未知异常了。
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
996
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部