procedure ExceptionHandler(Sender: TObject; EInstance: Exception);
var
msgError: string;
begin
if EInstance is EDivByZero then
msgError := '除数不能为零!'
else if EInstance is EAccessViolation then
msgError := '访问了无效的内存区域!'
else if (EInstance is EDatabaseError) then
msgError := '数据库操作出现错误!'
else if (EInstance is EFOpenError) then
msgError := '文件不能打开!'
else if (EInstance is EConvertError) then
msgError := '非法的类型转换!'
else if (Pos('General network error', EInstance.Message) > 0)
or (Pos('Connection failure', EInstance.Message) > 0)
or (Pos('SQL Server does not exist or access denied', EInstance.Message) > 0) then
begin
try
FCon.Connected := False;
FCon.Connected := True;
except
FCon.Connected := False;
msgError := '对不起连接(网络)失败,请稍后再试!';
end;
end
else
msgError := '未知错误';
//系统提示内容
MsgError := #13 + '系统提示:' + (Sender as TComponent).Name + ' ' + EInstance.ClassName + '' + EInstance.Message;
WriteLog('错误:' + DateTimetoStr(Now) + ' ' + UserName
+ #13 + msgError);
GetErrorPicture(msgError);
if (EInstance is EDatabaseError) then
begin
with FCon.Errors do
begin
WriteLog(#13 + 'Number:' + InttoStr(Item[0].Number)
+ 'Source:' + Item[0].Source
+ 'Description:' + Item[0].Description
+ 'HelpFile:' + Item[0].HelpFile
+ #13
+ 'HelpContext:' + InttoStr(Item[0].HelpContext)
+ 'SQLState:' + Item[0].SQLState
+ 'NativeError:' + InttoStr(Item[0].NativeError));
end;
end;
end;