mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
THRIFT-5004 Make exception implementations more consistent [ci skip]
Client: Delphi Patch: Jens Geyer
This commit is contained in:
parent
24fa9d0728
commit
9f11c1e545
@ -112,24 +112,27 @@ type
|
|||||||
function GetProtocol( const trans: ITransport): IProtocol;
|
function GetProtocol( const trans: ITransport): IProtocol;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TProtocolException = class( TException)
|
TProtocolException = class abstract( TException)
|
||||||
public
|
public
|
||||||
const // TODO(jensg): change into enum
|
type TExceptionType = (
|
||||||
UNKNOWN = 0;
|
UNKNOWN = 0,
|
||||||
INVALID_DATA = 1;
|
INVALID_DATA = 1,
|
||||||
NEGATIVE_SIZE = 2;
|
NEGATIVE_SIZE = 2,
|
||||||
SIZE_LIMIT = 3;
|
SIZE_LIMIT = 3,
|
||||||
BAD_VERSION = 4;
|
BAD_VERSION = 4,
|
||||||
NOT_IMPLEMENTED = 5;
|
NOT_IMPLEMENTED = 5,
|
||||||
DEPTH_LIMIT = 6;
|
DEPTH_LIMIT = 6
|
||||||
|
);
|
||||||
protected
|
protected
|
||||||
constructor HiddenCreate(const Msg: string);
|
constructor HiddenCreate(const Msg: string);
|
||||||
|
class function GetType: TExceptionType; virtual; abstract;
|
||||||
public
|
public
|
||||||
// purposefully hide inherited constructor
|
// purposefully hide inherited constructor
|
||||||
class function Create(const Msg: string): TProtocolException; overload; deprecated 'Use specialized TProtocolException types (or regenerate from IDL)';
|
class function Create(const Msg: string): TProtocolException; overload; deprecated 'Use specialized TProtocolException types (or regenerate from IDL)';
|
||||||
class function Create: TProtocolException; overload; deprecated 'Use specialized TProtocolException types (or regenerate from IDL)';
|
class function Create: TProtocolException; overload; deprecated 'Use specialized TProtocolException types (or regenerate from IDL)';
|
||||||
class function Create( type_: Integer): TProtocolException; overload; deprecated 'Use specialized TProtocolException types (or regenerate from IDL)';
|
class function Create( aType: TExceptionType): TProtocolException; overload; deprecated 'Use specialized TProtocolException types (or regenerate from IDL)';
|
||||||
class function Create( type_: Integer; const msg: string): TProtocolException; overload; deprecated 'Use specialized TProtocolException types (or regenerate from IDL)';
|
class function Create( aType: TExceptionType; const msg: string): TProtocolException; overload; deprecated 'Use specialized TProtocolException types (or regenerate from IDL)';
|
||||||
|
property Type_: TExceptionType read GetType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Needed to remove deprecation warning
|
// Needed to remove deprecation warning
|
||||||
@ -138,13 +141,41 @@ type
|
|||||||
constructor Create(const Msg: string);
|
constructor Create(const Msg: string);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TProtocolExceptionUnknown = class (TProtocolExceptionSpecialized);
|
TProtocolExceptionUnknown = class (TProtocolExceptionSpecialized)
|
||||||
TProtocolExceptionInvalidData = class (TProtocolExceptionSpecialized);
|
protected
|
||||||
TProtocolExceptionNegativeSize = class (TProtocolExceptionSpecialized);
|
class function GetType: TProtocolException.TExceptionType; override;
|
||||||
TProtocolExceptionSizeLimit = class (TProtocolExceptionSpecialized);
|
end;
|
||||||
TProtocolExceptionBadVersion = class (TProtocolExceptionSpecialized);
|
|
||||||
TProtocolExceptionNotImplemented = class (TProtocolExceptionSpecialized);
|
TProtocolExceptionInvalidData = class (TProtocolExceptionSpecialized)
|
||||||
TProtocolExceptionDepthLimit = class (TProtocolExceptionSpecialized);
|
protected
|
||||||
|
class function GetType: TProtocolException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TProtocolExceptionNegativeSize = class (TProtocolExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TProtocolException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TProtocolExceptionSizeLimit = class (TProtocolExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TProtocolException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TProtocolExceptionBadVersion = class (TProtocolExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TProtocolException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TProtocolExceptionNotImplemented = class (TProtocolExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TProtocolException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TProtocolExceptionDepthLimit = class (TProtocolExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TProtocolException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TProtocolUtil = class
|
TProtocolUtil = class
|
||||||
@ -1000,23 +1031,24 @@ begin
|
|||||||
Result := TProtocolExceptionUnknown.Create('');
|
Result := TProtocolExceptionUnknown.Create('');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TProtocolException.Create(type_: Integer): TProtocolException;
|
class function TProtocolException.Create(aType: TExceptionType): TProtocolException;
|
||||||
begin
|
begin
|
||||||
{$WARN SYMBOL_DEPRECATED OFF}
|
{$WARN SYMBOL_DEPRECATED OFF}
|
||||||
Result := Create(type_, '');
|
Result := Create(aType, '');
|
||||||
{$WARN SYMBOL_DEPRECATED DEFAULT}
|
{$WARN SYMBOL_DEPRECATED DEFAULT}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TProtocolException.Create(type_: Integer; const msg: string): TProtocolException;
|
class function TProtocolException.Create(aType: TExceptionType; const msg: string): TProtocolException;
|
||||||
begin
|
begin
|
||||||
case type_ of
|
case aType of
|
||||||
INVALID_DATA: Result := TProtocolExceptionInvalidData.Create(msg);
|
TExceptionType.INVALID_DATA: Result := TProtocolExceptionInvalidData.Create(msg);
|
||||||
NEGATIVE_SIZE: Result := TProtocolExceptionNegativeSize.Create(msg);
|
TExceptionType.NEGATIVE_SIZE: Result := TProtocolExceptionNegativeSize.Create(msg);
|
||||||
SIZE_LIMIT: Result := TProtocolExceptionSizeLimit.Create(msg);
|
TExceptionType.SIZE_LIMIT: Result := TProtocolExceptionSizeLimit.Create(msg);
|
||||||
BAD_VERSION: Result := TProtocolExceptionBadVersion.Create(msg);
|
TExceptionType.BAD_VERSION: Result := TProtocolExceptionBadVersion.Create(msg);
|
||||||
NOT_IMPLEMENTED: Result := TProtocolExceptionNotImplemented.Create(msg);
|
TExceptionType.NOT_IMPLEMENTED: Result := TProtocolExceptionNotImplemented.Create(msg);
|
||||||
DEPTH_LIMIT: Result := TProtocolExceptionDepthLimit.Create(msg);
|
TExceptionType.DEPTH_LIMIT: Result := TProtocolExceptionDepthLimit.Create(msg);
|
||||||
else
|
else
|
||||||
|
ASSERT( TExceptionType.UNKNOWN = aType);
|
||||||
Result := TProtocolExceptionUnknown.Create(msg);
|
Result := TProtocolExceptionUnknown.Create(msg);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1028,6 +1060,43 @@ begin
|
|||||||
inherited HiddenCreate(Msg);
|
inherited HiddenCreate(Msg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ specialized TProtocolExceptions }
|
||||||
|
|
||||||
|
class function TProtocolExceptionUnknown.GetType: TProtocolException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.UNKNOWN;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TProtocolExceptionInvalidData.GetType: TProtocolException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.INVALID_DATA;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TProtocolExceptionNegativeSize.GetType: TProtocolException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.NEGATIVE_SIZE;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TProtocolExceptionSizeLimit.GetType: TProtocolException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.SIZE_LIMIT;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TProtocolExceptionBadVersion.GetType: TProtocolException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.BAD_VERSION;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TProtocolExceptionNotImplemented.GetType: TProtocolException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.NOT_IMPLEMENTED;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TProtocolExceptionDepthLimit.GetType: TProtocolException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.DEPTH_LIMIT;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TBinaryProtocolImpl.TFactory }
|
{ TBinaryProtocolImpl.TFactory }
|
||||||
|
|
||||||
constructor TBinaryProtocolImpl.TFactory.Create(AStrictRead, AStrictWrite: Boolean);
|
constructor TBinaryProtocolImpl.TFactory.Create(AStrictRead, AStrictWrite: Boolean);
|
||||||
|
@ -81,7 +81,7 @@ type
|
|||||||
procedure Flush; virtual;
|
procedure Flush; virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TTransportException = class( TException)
|
TTransportException = class abstract( TException)
|
||||||
public
|
public
|
||||||
type
|
type
|
||||||
TExceptionType = (
|
TExceptionType = (
|
||||||
@ -93,10 +93,9 @@ type
|
|||||||
BadArgs,
|
BadArgs,
|
||||||
Interrupted
|
Interrupted
|
||||||
);
|
);
|
||||||
private
|
|
||||||
function GetType: TExceptionType;
|
|
||||||
protected
|
protected
|
||||||
constructor HiddenCreate(const Msg: string);
|
constructor HiddenCreate(const Msg: string);
|
||||||
|
class function GetType: TExceptionType; virtual; abstract;
|
||||||
public
|
public
|
||||||
class function Create( AType: TExceptionType): TTransportException; overload; deprecated 'Use specialized TTransportException types (or regenerate from IDL)';
|
class function Create( AType: TExceptionType): TTransportException; overload; deprecated 'Use specialized TTransportException types (or regenerate from IDL)';
|
||||||
class function Create( const msg: string): TTransportException; reintroduce; overload; deprecated 'Use specialized TTransportException types (or regenerate from IDL)';
|
class function Create( const msg: string): TTransportException; reintroduce; overload; deprecated 'Use specialized TTransportException types (or regenerate from IDL)';
|
||||||
@ -110,13 +109,40 @@ type
|
|||||||
constructor Create(const Msg: string);
|
constructor Create(const Msg: string);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TTransportExceptionUnknown = class (TTransportExceptionSpecialized);
|
TTransportExceptionUnknown = class (TTransportExceptionSpecialized)
|
||||||
TTransportExceptionNotOpen = class (TTransportExceptionSpecialized);
|
protected
|
||||||
TTransportExceptionAlreadyOpen = class (TTransportExceptionSpecialized);
|
class function GetType: TTransportException.TExceptionType; override;
|
||||||
TTransportExceptionTimedOut = class (TTransportExceptionSpecialized);
|
end;
|
||||||
TTransportExceptionEndOfFile = class (TTransportExceptionSpecialized);
|
|
||||||
TTransportExceptionBadArgs = class (TTransportExceptionSpecialized);
|
TTransportExceptionNotOpen = class (TTransportExceptionSpecialized)
|
||||||
TTransportExceptionInterrupted = class (TTransportExceptionSpecialized);
|
protected
|
||||||
|
class function GetType: TTransportException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TTransportExceptionAlreadyOpen = class (TTransportExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TTransportException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TTransportExceptionTimedOut = class (TTransportExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TTransportException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TTransportExceptionEndOfFile = class (TTransportExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TTransportException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TTransportExceptionBadArgs = class (TTransportExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TTransportException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TTransportExceptionInterrupted = class (TTransportExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TTransportException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
TSecureProtocol = (
|
TSecureProtocol = (
|
||||||
SSL_2, SSL_3, TLS_1, // outdated, for compatibilty only
|
SSL_2, SSL_3, TLS_1, // outdated, for compatibilty only
|
||||||
@ -446,17 +472,6 @@ end;
|
|||||||
|
|
||||||
{ TTransportException }
|
{ TTransportException }
|
||||||
|
|
||||||
function TTransportException.GetType: TExceptionType;
|
|
||||||
begin
|
|
||||||
if Self is TTransportExceptionNotOpen then Result := TExceptionType.NotOpen
|
|
||||||
else if Self is TTransportExceptionAlreadyOpen then Result := TExceptionType.AlreadyOpen
|
|
||||||
else if Self is TTransportExceptionTimedOut then Result := TExceptionType.TimedOut
|
|
||||||
else if Self is TTransportExceptionEndOfFile then Result := TExceptionType.EndOfFile
|
|
||||||
else if Self is TTransportExceptionBadArgs then Result := TExceptionType.BadArgs
|
|
||||||
else if Self is TTransportExceptionInterrupted then Result := TExceptionType.Interrupted
|
|
||||||
else Result := TExceptionType.Unknown;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TTransportException.HiddenCreate(const Msg: string);
|
constructor TTransportException.HiddenCreate(const Msg: string);
|
||||||
begin
|
begin
|
||||||
inherited Create(Msg);
|
inherited Create(Msg);
|
||||||
@ -470,8 +485,7 @@ begin
|
|||||||
{$WARN SYMBOL_DEPRECATED DEFAULT}
|
{$WARN SYMBOL_DEPRECATED DEFAULT}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TTransportException.Create(AType: TExceptionType;
|
class function TTransportException.Create(aType: TExceptionType; const msg: string): TTransportException;
|
||||||
const msg: string): TTransportException;
|
|
||||||
begin
|
begin
|
||||||
case AType of
|
case AType of
|
||||||
TExceptionType.NotOpen: Result := TTransportExceptionNotOpen.Create(msg);
|
TExceptionType.NotOpen: Result := TTransportExceptionNotOpen.Create(msg);
|
||||||
@ -481,6 +495,7 @@ begin
|
|||||||
TExceptionType.BadArgs: Result := TTransportExceptionBadArgs.Create(msg);
|
TExceptionType.BadArgs: Result := TTransportExceptionBadArgs.Create(msg);
|
||||||
TExceptionType.Interrupted: Result := TTransportExceptionInterrupted.Create(msg);
|
TExceptionType.Interrupted: Result := TTransportExceptionInterrupted.Create(msg);
|
||||||
else
|
else
|
||||||
|
ASSERT( TExceptionType.Unknown = aType);
|
||||||
Result := TTransportExceptionUnknown.Create(msg);
|
Result := TTransportExceptionUnknown.Create(msg);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -497,6 +512,43 @@ begin
|
|||||||
inherited HiddenCreate(Msg);
|
inherited HiddenCreate(Msg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ specialized TTransportExceptions }
|
||||||
|
|
||||||
|
class function TTransportExceptionUnknown.GetType: TTransportException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.Unknown;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TTransportExceptionNotOpen.GetType: TTransportException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.NotOpen;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TTransportExceptionAlreadyOpen.GetType: TTransportException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.AlreadyOpen;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TTransportExceptionTimedOut.GetType: TTransportException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.TimedOut;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TTransportExceptionEndOfFile.GetType: TTransportException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.EndOfFile;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TTransportExceptionBadArgs.GetType: TTransportException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.BadArgs;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TTransportExceptionInterrupted.GetType: TTransportException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.Interrupted;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTransportFactoryImpl }
|
{ TTransportFactoryImpl }
|
||||||
|
|
||||||
function TTransportFactoryImpl.GetTransport( const ATrans: ITransport): ITransport;
|
function TTransportFactoryImpl.GetTransport( const ATrans: ITransport): ITransport;
|
||||||
|
@ -34,7 +34,7 @@ type
|
|||||||
|
|
||||||
TApplicationExceptionSpecializedClass = class of TApplicationExceptionSpecialized;
|
TApplicationExceptionSpecializedClass = class of TApplicationExceptionSpecialized;
|
||||||
|
|
||||||
TApplicationException = class( TException)
|
TApplicationException = class abstract( TException)
|
||||||
public
|
public
|
||||||
type
|
type
|
||||||
{$SCOPEDENUMS ON}
|
{$SCOPEDENUMS ON}
|
||||||
@ -52,10 +52,10 @@ type
|
|||||||
UnsupportedClientType
|
UnsupportedClientType
|
||||||
);
|
);
|
||||||
{$SCOPEDENUMS OFF}
|
{$SCOPEDENUMS OFF}
|
||||||
private
|
|
||||||
function GetType: TExceptionType;
|
|
||||||
protected
|
protected
|
||||||
constructor HiddenCreate(const Msg: string);
|
constructor HiddenCreate(const Msg: string);
|
||||||
|
class function GetType: TExceptionType; virtual; abstract;
|
||||||
|
class function GetSpecializedExceptionType(AType: TExceptionType): TApplicationExceptionSpecializedClass;
|
||||||
public
|
public
|
||||||
// purposefully hide inherited constructor
|
// purposefully hide inherited constructor
|
||||||
class function Create(const Msg: string): TApplicationException; overload; deprecated 'Use specialized TApplicationException types (or regenerate from IDL)';
|
class function Create(const Msg: string): TApplicationException; overload; deprecated 'Use specialized TApplicationException types (or regenerate from IDL)';
|
||||||
@ -63,7 +63,7 @@ type
|
|||||||
class function Create( AType: TExceptionType): TApplicationException; overload; deprecated 'Use specialized TApplicationException types (or regenerate from IDL)';
|
class function Create( AType: TExceptionType): TApplicationException; overload; deprecated 'Use specialized TApplicationException types (or regenerate from IDL)';
|
||||||
class function Create( AType: TExceptionType; const msg: string): TApplicationException; overload; deprecated 'Use specialized TApplicationException types (or regenerate from IDL)';
|
class function Create( AType: TExceptionType; const msg: string): TApplicationException; overload; deprecated 'Use specialized TApplicationException types (or regenerate from IDL)';
|
||||||
|
|
||||||
class function GetSpecializedExceptionType(AType: TExceptionType): TApplicationExceptionSpecializedClass;
|
property Type_: TExceptionType read GetType;
|
||||||
|
|
||||||
class function Read( const iprot: IProtocol): TApplicationException;
|
class function Read( const iprot: IProtocol): TApplicationException;
|
||||||
procedure Write( const oprot: IProtocol );
|
procedure Write( const oprot: IProtocol );
|
||||||
@ -75,38 +75,67 @@ type
|
|||||||
constructor Create(const Msg: string);
|
constructor Create(const Msg: string);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TApplicationExceptionUnknown = class (TApplicationExceptionSpecialized);
|
TApplicationExceptionUnknown = class (TApplicationExceptionSpecialized)
|
||||||
TApplicationExceptionUnknownMethod = class (TApplicationExceptionSpecialized);
|
protected
|
||||||
TApplicationExceptionInvalidMessageType = class (TApplicationExceptionSpecialized);
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
TApplicationExceptionWrongMethodName = class (TApplicationExceptionSpecialized);
|
end;
|
||||||
TApplicationExceptionBadSequenceID = class (TApplicationExceptionSpecialized);
|
|
||||||
TApplicationExceptionMissingResult = class (TApplicationExceptionSpecialized);
|
TApplicationExceptionUnknownMethod = class (TApplicationExceptionSpecialized)
|
||||||
TApplicationExceptionInternalError = class (TApplicationExceptionSpecialized);
|
protected
|
||||||
TApplicationExceptionProtocolError = class (TApplicationExceptionSpecialized);
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
TApplicationExceptionInvalidTransform = class (TApplicationExceptionSpecialized);
|
end;
|
||||||
TApplicationExceptionInvalidProtocol = class (TApplicationExceptionSpecialized);
|
|
||||||
TApplicationExceptionUnsupportedClientType = class (TApplicationExceptionSpecialized);
|
TApplicationExceptionInvalidMessageType = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TApplicationExceptionWrongMethodName = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TApplicationExceptionBadSequenceID = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TApplicationExceptionMissingResult = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TApplicationExceptionInternalError = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TApplicationExceptionProtocolError = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TApplicationExceptionInvalidTransform = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TApplicationExceptionInvalidProtocol = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TApplicationExceptionUnsupportedClientType = class (TApplicationExceptionSpecialized)
|
||||||
|
protected
|
||||||
|
class function GetType: TApplicationException.TExceptionType; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TApplicationException }
|
{ TApplicationException }
|
||||||
|
|
||||||
function TApplicationException.GetType: TExceptionType;
|
|
||||||
begin
|
|
||||||
if Self is TApplicationExceptionUnknownMethod then Result := TExceptionType.UnknownMethod
|
|
||||||
else if Self is TApplicationExceptionInvalidMessageType then Result := TExceptionType.InvalidMessageType
|
|
||||||
else if Self is TApplicationExceptionWrongMethodName then Result := TExceptionType.WrongMethodName
|
|
||||||
else if Self is TApplicationExceptionBadSequenceID then Result := TExceptionType.BadSequenceID
|
|
||||||
else if Self is TApplicationExceptionMissingResult then Result := TExceptionType.MissingResult
|
|
||||||
else if Self is TApplicationExceptionInternalError then Result := TExceptionType.InternalError
|
|
||||||
else if Self is TApplicationExceptionProtocolError then Result := TExceptionType.ProtocolError
|
|
||||||
else if Self is TApplicationExceptionInvalidTransform then Result := TExceptionType.InvalidTransform
|
|
||||||
else if Self is TApplicationExceptionInvalidProtocol then Result := TExceptionType.InvalidProtocol
|
|
||||||
else if Self is TApplicationExceptionUnsupportedClientType then Result := TExceptionType.UnsupportedClientType
|
|
||||||
else Result := TExceptionType.Unknown;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TApplicationException.HiddenCreate(const Msg: string);
|
constructor TApplicationException.HiddenCreate(const Msg: string);
|
||||||
begin
|
begin
|
||||||
inherited Create(Msg);
|
inherited Create(Msg);
|
||||||
@ -148,10 +177,12 @@ begin
|
|||||||
TExceptionType.InvalidProtocol: Result := TApplicationExceptionInvalidProtocol;
|
TExceptionType.InvalidProtocol: Result := TApplicationExceptionInvalidProtocol;
|
||||||
TExceptionType.UnsupportedClientType: Result := TApplicationExceptionUnsupportedClientType;
|
TExceptionType.UnsupportedClientType: Result := TApplicationExceptionUnsupportedClientType;
|
||||||
else
|
else
|
||||||
|
ASSERT( TExceptionType.Unknown = aType);
|
||||||
Result := TApplicationExceptionUnknown;
|
Result := TApplicationExceptionUnknown;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
class function TApplicationException.Read( const iprot: IProtocol): TApplicationException;
|
class function TApplicationException.Read( const iprot: IProtocol): TApplicationException;
|
||||||
var
|
var
|
||||||
field : TThriftField;
|
field : TThriftField;
|
||||||
@ -236,4 +267,62 @@ begin
|
|||||||
inherited HiddenCreate(Msg);
|
inherited HiddenCreate(Msg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ specialized TApplicationExceptions }
|
||||||
|
|
||||||
|
class function TApplicationExceptionUnknownMethod.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.UnknownMethod;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionInvalidMessageType.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.InvalidMessageType;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionWrongMethodName.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.WrongMethodName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionBadSequenceID.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.BadSequenceID;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionMissingResult.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.MissingResult;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionInternalError.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.InternalError;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionProtocolError.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.ProtocolError;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionInvalidTransform.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.InvalidTransform;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionInvalidProtocol.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.InvalidProtocol;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionUnsupportedClientType.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.UnsupportedClientType;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TApplicationExceptionUnknown.GetType : TApplicationException.TExceptionType;
|
||||||
|
begin
|
||||||
|
result := TExceptionType.Unknown;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user