📄 adexcept.pas
字号:
ETapiInvalTimeout = class(ETapi);
ETapiInvalTone = class(ETapi);
ETapiInvalToneList = class(ETapi);
ETapiInvalToneMode = class(ETapi);
ETapiInvalTransferMode = class(ETapi);
ETapiLineMapperFailed = class(ETapi);
ETapiNoConference = class(ETapi);
ETapiNoDevice = class(ETapi);
ETapiNoDriver = class(ETapi);
ETapiNoMem = class(ETapi);
ETapiNoRequest = class(ETapi);
ETapiNotOwner = class(ETapi);
ETapiNotRegistered = class(ETapi);
ETapiOperationFailed = class(ETapi);
ETapiOperationUnavail = class(ETapi);
ETapiRateUnavail = class(ETapi);
ETapiResourceUnavail = class(ETapi);
ETapiRequestOverrun = class(ETapi);
ETapiStructureTooSmall = class(ETapi);
ETapiTargetNotFound = class(ETapi);
ETapiTargetSelf = class(ETapi);
ETapiUninitialized = class(ETapi);
ETapiUserUserInfoTooBig = class(ETapi);
ETapiReinit = class(ETapi);
ETapiAddressBlocked = class(ETapi);
ETapiBillingRejected = class(ETapi);
ETapiInvalFeature = class(ETapi);
ETapiNoMultipleInstance = class(ETapi);
{Tapi exceptions that don't simply mirror TAPI error codes}
ETapiBusy = class(ETapi);
ETapiNotSet = class(ETapi);
ETapiNoSelect = class(ETapi);
ETapiLoadFail = class(ETapi);
ETapiGetAddrFail = class(ETapi);
ETapiUnexpected = class(ETapi);
ETapiVoiceNotSupported = class(ETapi);
ETapiWaveFail = class(ETapi);
ETapiTranslateFail = class(ETapi);
{VoIP specific errors}
EVoIPNotSupported = class(ETapi);
{Ras exceptions}
ERasLoadFail = class(ERas);
{Terminal exceptions}
EAdTerminalClass = class of EAdTerminal;
EAdTermRangeError = class(EAdTerminal);
EAdTermInvalidParameter = class(EAdTerminal);
EAdTermTooLarge = class(EAdTerminal);
{TApdPager Exceptions}
EApdPagerException = class (Exception)
private
FErrorCode : Integer;
public
{ Parameters to the construtor are reversed to prevent problems with
C++ Builder }
constructor Create (const ErrCode : Integer; const Msg : string);
published
property ErrorCode : Integer read FErrorCode;
end;
{TApdGSMPhone Exceptions}
EApdGSMPhoneException = class (Exception)
private
FErrorCode : Integer;
public
{ Parameters to the construtor are reversed to prevent problems with
C++ Builder }
constructor Create (const ErrCode : Integer; const Msg : string);
published
property ErrorCode : Integer read FErrorCode;
end;
{ XML exceptions }
EAdStreamError = class(EXML)
private
seFilePos : Longint;
public
constructor CreateError(const FilePos : Longint;
const Reason : DOMString);
property FilePos : Longint
read seFilePos;
end;
EAdFilterError = class(EAdStreamError)
private
feReason : DOMString;
feLine : Longint;
feLinePos : Longint;
public
constructor CreateError(const FilePos, Line, LinePos : Longint;
const Reason : DOMString);
property Reason : DOMString
read feReason;
property Line : Longint
read feLine;
property LinePos : Longint
read feLinePos;
end;
EAdParserError = class(EAdFilterError)
protected
public
constructor CreateError(Line, LinePos : Longint;
const Reason : DOMString);
end;
function CheckException(const Ctl : TComponent;
const Res : Integer) : Integer;
function XlatException(const E : Exception) : Integer;
{-Translate an exception into an error code}
function AproLoadStr(const ErrorCode : SmallInt) : ShortString;
function AproLoadZ(P : PChar; Code : Integer) : PChar;
function ErrorMsg(const ErrorCode : SmallInt) : ShortString;
{$IFDEF UseResourceStrings}
function MessageNumberToString(MessageNumber : SmallInt) : ShortString;
{$ENDIF}
{.Z-}
{$IFNDEF UseResourceStrings}
var {!!.02}
AproStrRes : TAdStringResource; {!!.02}
{$ENDIF}
implementation
{$IFDEF UseResourceStrings}
{ include AdStrMap here to prevent circular references in AdStrMap }
uses
AdStrMap;
{$ENDIF}
function AproLoadZ(P : PChar; Code : Integer) : PChar;
begin
{$IFDEF UseResourceStrings}
Result := StrPCopy(P, AproLoadStr(Code));
{$ELSE}
Result := AproStrRes.GetAsciiZ(Abs(Code), P, MaxMessageLen);
{$ENDIF}
end;
function AproLoadStr(const ErrorCode : SmallInt) : ShortString;
{-Return an error message for ErrorCode}
var
Buffer : array[0..255] of Char;
function TrimWhite(const S : ShortString) : ShortString;
var
i : Integer;
begin
Result := S;
for i := length(Result) downto 1 do
if Result[i] < ' ' then
Result[i] := ' ';
i := pos(' ',Result);
while i <> 0 do begin
delete(Result,i,1);
i := pos(' ',Result);
end;
end;
begin
{$IFDEF UseResourceStrings}
Result := MessageNumberToString(ErrorCode);
{$ELSE}
Result := AproStrRes.GetString(abs(ErrorCode));
{$ENDIF}
if Result = '' then begin
if FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,nil,abs(ErrorCode),0,
Buffer,255,nil) > 0 then
Result := TrimWhite(StrPas(Buffer));
end;
end;
{Alias for function above}
function ErrorMsg(const ErrorCode : SmallInt) : ShortString;
{-Return an error message for ErrorCode}
begin
Result := AproLoadStr(ErrorCode);
end;
{$IFDEF UseResourceStrings}
function MessageNumberToString(MessageNumber : SmallInt) : ShortString;
var
Middle : integer;
Min : integer;
Max : integer;
begin
Result := '';
Min := 0;
Max := AdMaxMessages;
MessageNumber := abs(MessageNumber);
while (Min <= Max) do begin
Middle := Round ((Min + Max) / 2);
if abs(AdMessageNumberLookup[Middle].MessageNumber) = abs(MessageNumber) then begin
{ found it }
Result := AdMessageNumberLookup[Middle].MessageString;
Exit;
end else if abs(MessageNumber) < abs(AdMessageNumberLookup[Middle].MessageNumber) then
Max := Middle - 1
else
Min := Middle + 1;
end;
end;
{$ENDIF}
constructor EAPDException.Create(const EC : Integer; PassThru : Boolean);
begin
FErrorCode := EC;
inherited Create(AproLoadStr(Abs(EC)));
end;
constructor EAPDException.CreateUnknown(const Msg : String; Dummy : Byte);
begin
ErrorCode := 0;
inherited Create(Msg);
end;
class function EAPDException.MapCodeToStringID(const Code : Integer) : Word;
begin
Result := Abs(Code);
end;
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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -