function CheckException(
const Ctl : TComponent;
const Res : Integer) : Integer;
{-Check Res, raise appropriate exception if non-zero}
var
ErrorMsg :
String;
FileIO : EInOutError;
begin
Result := Res;
if (Res < ecOk)
then
if not (csLoading
in Ctl.ComponentState)
then begin
case Res
of
ecHardwareFailure..ecFileNotFound:
begin
{find the error message for the error}
ErrorMsg := AproLoadStr(Abs(Res));
{if we've run out of memory, raise that exception}
if (Res = ecOutOfMemory)
then
OutOfMemoryError
{otherwise, raise a file I/O exception}
else begin
FileIO := EInOutError.Create(ErrorMsg);
FileIO.ErrorCode := Abs(Res);
raise FileIO;
end;
end;
{EGeneral}
ecBadArgument :
raise EBadArgument.Create(Res, False);
ecGotQuitMsg :
raise EGotQuitMsg.Create(Res, False);
ecBufferTooBig :
raise EBufferTooBig.Create(Res, False);
ecPortNotAssigned :
raise EPortNotAssigned.Create(Res, False);
ecInternal,
ecNoFieldsDefined,
ecNoIndexKey,
ecDatabaseNotPrepared :
raise EInternal.Create(Res, False);
ecModemNotAssigned :
raise EModemNotAssigned.Create(Res, False);
ecPhonebookNotAssigned :
raise EPhonebookNotAssigned.Create(Res, False);
ecCannotUseWithWinSock :
raise ECannotUseWithWinsock.Create(Res, False);
{EOpenComm}
ecBadId :
raise EBadId.Create(Res, False);
ecBaudRate :
raise EBaudRate.Create(Res, False);
ecByteSize :
raise EByteSize.Create(Res, False);
ecDefault :
raise EDefault.Create(Res, False);
ecHardware :
raise EHardware.Create(Res, False);
ecMemory :
raise EMemory.Create(Res, False);
ecCommNotOpen :
raise ECommNotOpen.Create(Res, False);
(...)