From: Roger Meier Date: Sat, 22 Dec 2012 20:31:03 +0000 (+0100) Subject: THRIFT-1801 Sync up TApplicationException codes across languages and thrift implement... X-Git-Tag: 0.9.1~217^2~2 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=0193149842924b65c5d3761d60055d298470d3ab;p=common%2Fthrift.git THRIFT-1801 Sync up TApplicationException codes across languages and thrift implementations Patch: Andrew Cox --- diff --git a/lib/as3/src/org/apache/thrift/TApplicationError.as b/lib/as3/src/org/apache/thrift/TApplicationError.as index aa3278df..3448fce0 100644 --- a/lib/as3/src/org/apache/thrift/TApplicationError.as +++ b/lib/as3/src/org/apache/thrift/TApplicationError.as @@ -42,11 +42,14 @@ package org.apache.thrift { public static const MISSING_RESULT:int = 5; public static const INTERNAL_ERROR:int = 6; public static const PROTOCOL_ERROR:int = 7; + public static const INVALID_TRANSFORM:int = 8; + public static const INVALID_PROTOCOL:int = 9; + public static const UNSUPPORTED_CLIENT_TYPE:int = 10; public function TApplicationError(type:int = UNKNOWN, message:String = "") { super(message, type); } - + public static function read(iprot:TProtocol):TApplicationError { var field:TField; iprot.readStructBegin(); diff --git a/lib/c_glib/src/thrift/thrift_application_exception.h b/lib/c_glib/src/thrift/thrift_application_exception.h index be5a8c0e..580f4fc1 100644 --- a/lib/c_glib/src/thrift/thrift_application_exception.h +++ b/lib/c_glib/src/thrift/thrift_application_exception.h @@ -67,7 +67,10 @@ typedef enum THRIFT_APPLICATION_EXCEPTION_ERROR_BAD_SEQUENCE_ID, THRIFT_APPLICATION_EXCEPTION_ERROR_MISSING_RESULT, THRIFT_APPLICATION_EXCEPTION_ERROR_INTERNAL_ERROR, - THRIFT_APPLICATION_EXCEPTION_ERROR_PROTOCOL_ERROR + THRIFT_APPLICATION_EXCEPTION_ERROR_PROTOCOL_ERROR, + THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_TRANSFORM, + THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_PROTOCOL, + THRIFT_APPLICATION_EXCEPTION_ERROR_UNSUPPORTED_CLIENT_TYPE } ThriftApplicationExceptionError; /* define error domain for GError */ diff --git a/lib/cocoa/src/TApplicationException.h b/lib/cocoa/src/TApplicationException.h index 0ad0b9ad..7b027d67 100644 --- a/lib/cocoa/src/TApplicationException.h +++ b/lib/cocoa/src/TApplicationException.h @@ -28,7 +28,10 @@ enum { TApplicationException_BAD_SEQUENCE_ID = 4, TApplicationException_MISSING_RESULT = 5, TApplicationException_INTERNAL_ERROR = 6, - TApplicationException_PROTOCOL_ERROR = 7 + TApplicationException_PROTOCOL_ERROR = 7, + TApplicationException_INVALID_TRANSFORM = 8, + TApplicationException_INVALID_PROTOCOL = 9, + TApplicationException_UNSUPPORTED_CLIENT_TYPE = 10 }; // FIXME diff --git a/lib/cocoa/src/TApplicationException.m b/lib/cocoa/src/TApplicationException.m index 66c2f2b1..974dfc50 100644 --- a/lib/cocoa/src/TApplicationException.m +++ b/lib/cocoa/src/TApplicationException.m @@ -45,6 +45,21 @@ case TApplicationException_MISSING_RESULT: name = @"Missing result"; break; + case TApplicationException_INTERNAL_ERROR: + name = @"Internal error"; + break; + case TApplicationException_PROTOCOL_ERROR: + name = @"Protocol error"; + break; + case TApplicationException_INVALID_TRANSFORM: + name = @"Invalid transform"; + break; + case TApplicationException_INVALID_PROTOCOL: + name = @"Invalid protocol"; + break; + case TApplicationException_UNSUPPORTED_CLIENT_TYPE: + name = @"Unsupported client type"; + break; default: name = @"Unknown"; break; diff --git a/lib/cpp/src/thrift/TApplicationException.h b/lib/cpp/src/thrift/TApplicationException.h index 79f026da..d32a21d5 100644 --- a/lib/cpp/src/thrift/TApplicationException.h +++ b/lib/cpp/src/thrift/TApplicationException.h @@ -43,7 +43,10 @@ class TApplicationException : public TException { BAD_SEQUENCE_ID = 4, MISSING_RESULT = 5, INTERNAL_ERROR = 6, - PROTOCOL_ERROR = 7 + PROTOCOL_ERROR = 7, + INVALID_TRANSFORM = 8, + INVALID_PROTOCOL = 9, + UNSUPPORTED_CLIENT_TYPE = 10 }; TApplicationException() : @@ -78,13 +81,18 @@ class TApplicationException : public TException { virtual const char* what() const throw() { if (message_.empty()) { switch (type_) { - case UNKNOWN : return "TApplicationException: Unknown application exception"; - case UNKNOWN_METHOD : return "TApplicationException: Unknown method"; - case INVALID_MESSAGE_TYPE : return "TApplicationException: Invalid message type"; - case WRONG_METHOD_NAME : return "TApplicationException: Wrong method name"; - case BAD_SEQUENCE_ID : return "TApplicationException: Bad sequence identifier"; - case MISSING_RESULT : return "TApplicationException: Missing result"; - default : return "TApplicationException: (Invalid exception type)"; + case UNKNOWN : return "TApplicationException: Unknown application exception"; + case UNKNOWN_METHOD : return "TApplicationException: Unknown method"; + case INVALID_MESSAGE_TYPE : return "TApplicationException: Invalid message type"; + case WRONG_METHOD_NAME : return "TApplicationException: Wrong method name"; + case BAD_SEQUENCE_ID : return "TApplicationException: Bad sequence identifier"; + case MISSING_RESULT : return "TApplicationException: Missing result"; + case INTERNAL_ERROR : return "TApplicationException: Internal error"; + case PROTOCOL_ERROR : return "TApplicationException: Protocol error"; + case INVALID_TRANSFORM : return "TApplicationException: Invalid transform"; + case INVALID_PROTOCOL : return "TApplicationException: Invalid protocol"; + case UNSUPPORTED_CLIENT_TYPE : return "TApplicationException: Unsupported client type"; + default : return "TApplicationException: (Invalid exception type)"; }; } else { return message_.c_str(); diff --git a/lib/csharp/src/TApplicationException.cs b/lib/csharp/src/TApplicationException.cs index 57dd375a..9aaf6f7f 100644 --- a/lib/csharp/src/TApplicationException.cs +++ b/lib/csharp/src/TApplicationException.cs @@ -130,7 +130,12 @@ namespace Thrift InvalidMessageType, WrongMethodName, BadSequenceID, - MissingResult + MissingResult, + InternalError, + ProtocolError, + InvalidTransform, + InvalidProtocol, + UnsupportedClientType } } } diff --git a/lib/d/src/thrift/protocol/base.d b/lib/d/src/thrift/protocol/base.d index 97cbb4da..bd65b711 100644 --- a/lib/d/src/thrift/protocol/base.d +++ b/lib/d/src/thrift/protocol/base.d @@ -345,7 +345,10 @@ class TApplicationException : TException { BAD_SEQUENCE_ID = 4, /// MISSING_RESULT = 5, /// INTERNAL_ERROR = 6, /// - PROTOCOL_ERROR = 7 /// + PROTOCOL_ERROR = 7, /// + INVALID_TRANSFORM = 8, /// + INVALID_PROTOCOL = 9, /// + UNSUPPORTED_CLIENT_TYPE = 10 /// } /// @@ -358,6 +361,11 @@ class TApplicationException : TException { case Type.WRONG_METHOD_NAME: return "Wrong method name"; case Type.BAD_SEQUENCE_ID: return "Bad sequence identifier"; case Type.MISSING_RESULT: return "Missing result"; + case Type.INTERNAL_ERROR: return "Internal error"; + case Type.PROTOCOL_ERROR: return "Protocol error"; + case Type.INVALID_TRANSFORM: return "Invalid transform"; + case Type.INVALID_PROTOCOL: return "Invalid protocol"; + case Type.UNSUPPORTED_CLIENT_TYPE: return "Unsupported client type"; default: return "(Invalid exception type)"; } } diff --git a/lib/delphi/src/Thrift.pas b/lib/delphi/src/Thrift.pas index 189640ac..44f12d78 100644 --- a/lib/delphi/src/Thrift.pas +++ b/lib/delphi/src/Thrift.pas @@ -43,7 +43,12 @@ type InvalidMessageType, WrongMethodName, BadSequenceID, - MissingResult + MissingResult, + InternalError, + ProtocolError, + InvalidTransform, + InvalidProtocol, + UnsupportedClientType ); {$SCOPEDENUMS OFF} private diff --git a/lib/erl/include/thrift_constants.hrl b/lib/erl/include/thrift_constants.hrl index 61d8e1a9..dbfaaf6f 100644 --- a/lib/erl/include/thrift_constants.hrl +++ b/lib/erl/include/thrift_constants.hrl @@ -53,4 +53,6 @@ -define(TApplicationException_MISSING_RESULT, 5). -define(TApplicationException_INTERNAL_ERROR, 6). -define(TApplicationException_PROTOCOL_ERROR, 7). - +-define(TApplicationException_INVALID_TRANSFORM, 8). +-define(TApplicationException_INVALID_PROTOCOL, 9). +-define(TApplicationException_UNSUPPORTED_CLIENT_TYPE, 10). diff --git a/lib/go/thrift/tapplication_exception.go b/lib/go/thrift/tapplication_exception.go index fc8bf2ec..6b7a75d5 100644 --- a/lib/go/thrift/tapplication_exception.go +++ b/lib/go/thrift/tapplication_exception.go @@ -32,6 +32,9 @@ const ( MISSING_RESULT = 5 INTERNAL_ERROR = 6 PROTOCOL_ERROR = 7 + INVALID_TRANSFORM = 8 + INVALID_PROTOCOL = 9 + UNSUPPORTED_CLIENT_TYPE = 10 ) diff --git a/lib/hs/src/Thrift.hs b/lib/hs/src/Thrift.hs index 42f5d321..65a22080 100644 --- a/lib/hs/src/Thrift.hs +++ b/lib/hs/src/Thrift.hs @@ -54,6 +54,9 @@ data AppExnType | AE_MISSING_RESULT | AE_INTERNAL_ERROR | AE_PROTOCOL_ERROR + | AE_INVALID_TRANSFORM + | AE_INVALID_PROTOCOL + | AE_UNSUPPORTED_CLIENT_TYPE deriving ( Eq, Show, Typeable ) instance Enum AppExnType where @@ -65,6 +68,9 @@ instance Enum AppExnType where toEnum 5 = AE_MISSING_RESULT toEnum 6 = AE_INTERNAL_ERROR toEnum 7 = AE_PROTOCOL_ERROR + toEnum 8 = AE_INVALID_TRANSFORM + toEnum 9 = AE_INVALID_PROTOCOL + toEnum 10 = AE_UNSUPPORTED_CLIENT_TYPE toEnum t = error $ "Invalid AppExnType " ++ show t fromEnum AE_UNKNOWN = 0 @@ -75,6 +81,9 @@ instance Enum AppExnType where fromEnum AE_MISSING_RESULT = 5 fromEnum AE_INTERNAL_ERROR = 6 fromEnum AE_PROTOCOL_ERROR = 7 + fromEnum AE_INVALID_TRANSFORM = 8 + fromEnum AE_INVALID_PROTOCOL = 9 + fromEnum AE_UNSUPPORTED_CLIENT_TYPE = 10 data AppExn = AppExn { ae_type :: AppExnType, ae_message :: String } deriving ( Show, Typeable ) diff --git a/lib/java/src/org/apache/thrift/TApplicationException.java b/lib/java/src/org/apache/thrift/TApplicationException.java index c294fc38..b54a5ce5 100644 --- a/lib/java/src/org/apache/thrift/TApplicationException.java +++ b/lib/java/src/org/apache/thrift/TApplicationException.java @@ -45,6 +45,9 @@ public class TApplicationException extends TException { public static final int MISSING_RESULT = 5; public static final int INTERNAL_ERROR = 6; public static final int PROTOCOL_ERROR = 7; + public static final int INVALID_TRANSFORM = 8; + public static final int INVALID_PROTOCOL = 9; + public static final int UNSUPPORTED_CLIENT_TYPE = 10; protected int type_ = UNKNOWN; diff --git a/lib/javame/src/org/apache/thrift/TApplicationException.java b/lib/javame/src/org/apache/thrift/TApplicationException.java index de9a162f..2f8612af 100644 --- a/lib/javame/src/org/apache/thrift/TApplicationException.java +++ b/lib/javame/src/org/apache/thrift/TApplicationException.java @@ -41,7 +41,9 @@ public class TApplicationException extends TException { public static final int MISSING_RESULT = 5; public static final int INTERNAL_ERROR = 6; public static final int PROTOCOL_ERROR = 7; - + public static final int INVALID_TRANSFORM = 8; + public static final int INVALID_PROTOCOL = 9; + public static final int UNSUPPORTED_CLIENT_TYPE = 10; protected int type_ = UNKNOWN; diff --git a/lib/js/thrift.js b/lib/js/thrift.js index cf89236e..39b0a5cc 100644 --- a/lib/js/thrift.js +++ b/lib/js/thrift.js @@ -87,7 +87,10 @@ Thrift.TApplicationExceptionType = { 'BAD_SEQUENCE_ID' : 4, 'MISSING_RESULT' : 5, 'INTERNAL_ERROR' : 6, - 'PROTOCOL_ERROR' : 7 + 'PROTOCOL_ERROR' : 7, + 'INVALID_TRANSFORM' : 8, + 'INVALID_PROTOCOL' : 9, + 'UNSUPPORTED_CLIENT_TYPE' : 10 }; Thrift.TApplicationException = function(message, code) { diff --git a/lib/nodejs/lib/thrift/thrift.js b/lib/nodejs/lib/thrift/thrift.js index 6c500a55..94223e35 100644 --- a/lib/nodejs/lib/thrift/thrift.js +++ b/lib/nodejs/lib/thrift/thrift.js @@ -59,7 +59,10 @@ var TApplicationExceptionType = exports.TApplicationExceptionType = { BAD_SEQUENCE_ID: 4, MISSING_RESULT: 5, INTERNAL_ERROR: 6, - PROTOCOL_ERROR: 7 + PROTOCOL_ERROR: 7, + INVALID_TRANSFORM: 8, + INVALID_PROTOCOL: 9, + UNSUPPORTED_CLIENT_TYPE: 10 } var TApplicationException = exports.TApplicationException = function(type, message) { diff --git a/lib/ocaml/src/Thrift.ml b/lib/ocaml/src/Thrift.ml index 8d423d01..f176a43b 100644 --- a/lib/ocaml/src/Thrift.ml +++ b/lib/ocaml/src/Thrift.ml @@ -294,6 +294,9 @@ struct | MISSING_RESULT | INTERNAL_ERROR | PROTOCOL_ERROR + | INVALID_TRANSFORM + | INVALID_PROTOCOL + | UNSUPPORTED_CLIENT_TYPE let typ_of_i = function 0l -> UNKNOWN @@ -304,6 +307,9 @@ struct | 5l -> MISSING_RESULT | 6l -> INTERNAL_ERROR | 7l -> PROTOCOL_ERROR + | 8l -> INVALID_TRANSFORM + | 9l -> INVALID_PROTOCOL + | 10l -> UNSUPPORTED_CLIENT_TYPE | _ -> raise Thrift_error;; let typ_to_i = function | UNKNOWN -> 0l @@ -314,6 +320,9 @@ struct | MISSING_RESULT -> 5l | INTERNAL_ERROR -> 6l | PROTOCOL_ERROR -> 7l + | INVALID_TRANSFORM -> 8l + | INVALID_PROTOCOL -> 9l + | UNSUPPORTED_CLIENT_TYPE -> 10l class t = object (self) diff --git a/lib/perl/lib/Thrift.pm b/lib/perl/lib/Thrift.pm index f5268031..67186f23 100644 --- a/lib/perl/lib/Thrift.pm +++ b/lib/perl/lib/Thrift.pm @@ -69,14 +69,17 @@ sub new { package TApplicationException; use base('Thrift::TException'); -use constant UNKNOWN => 0; -use constant UNKNOWN_METHOD => 1; -use constant INVALID_MESSAGE_TYPE => 2; -use constant WRONG_METHOD_NAME => 3; -use constant BAD_SEQUENCE_ID => 4; -use constant MISSING_RESULT => 5; -use constant INTERNAL_ERROR => 6; -use constant PROTOCOL_ERROR => 7; +use constant UNKNOWN => 0; +use constant UNKNOWN_METHOD => 1; +use constant INVALID_MESSAGE_TYPE => 2; +use constant WRONG_METHOD_NAME => 3; +use constant BAD_SEQUENCE_ID => 4; +use constant MISSING_RESULT => 5; +use constant INTERNAL_ERROR => 6; +use constant PROTOCOL_ERROR => 7; +use constant INVALID_TRANSFORM => 8; +use constant INVALID_PROTOCOL => 9; +use constant UNSUPPORTED_CLIENT_TYPE => 10; sub new { my $classname = shift; diff --git a/lib/php/lib/Thrift/Exception/TApplicationException.php b/lib/php/lib/Thrift/Exception/TApplicationException.php index 55d46e60..90819734 100644 --- a/lib/php/lib/Thrift/Exception/TApplicationException.php +++ b/lib/php/lib/Thrift/Exception/TApplicationException.php @@ -40,6 +40,9 @@ class TApplicationException extends TException { const MISSING_RESULT = 5; const INTERNAL_ERROR = 6; const PROTOCOL_ERROR = 7; + const INVALID_TRANSFORM = 8; + const INVALID_PROTOCOL = 9; + const UNSUPPORTED_CLIENT_TYPE = 10; function __construct($message=null, $code=0) { parent::__construct($message, $code); diff --git a/lib/py/src/Thrift.py b/lib/py/src/Thrift.py index 707a8ccc..9890af7e 100644 --- a/lib/py/src/Thrift.py +++ b/lib/py/src/Thrift.py @@ -101,6 +101,9 @@ class TApplicationException(TException): MISSING_RESULT = 5 INTERNAL_ERROR = 6 PROTOCOL_ERROR = 7 + INVALID_TRANSFORM = 8 + INVALID_PROTOCOL = 9 + UNSUPPORTED_CLIENT_TYPE = 10 def __init__(self, type=UNKNOWN, message=None): TException.__init__(self, message) @@ -119,6 +122,16 @@ class TApplicationException(TException): return 'Bad sequence ID' elif self.type == self.MISSING_RESULT: return 'Missing result' + elif self.type == self.INTERNAL_ERROR: + return 'Internal error' + elif self.type == self.PROTOCOL_ERROR: + return 'Protocol error' + elif self.type == self.INVALID_TRANSFORM: + return 'Invalid transform' + elif self.type == self.INVALID_PROTOCOL: + return 'Invalid protocol' + elif self.type == self.UNSUPPORTED_CLIENT_TYPE: + return 'Unsupported client type' else: return 'Default (unknown) TApplicationException' diff --git a/lib/rb/lib/thrift/exceptions.rb b/lib/rb/lib/thrift/exceptions.rb index 2ccc7ce6..68cb9e03 100644 --- a/lib/rb/lib/thrift/exceptions.rb +++ b/lib/rb/lib/thrift/exceptions.rb @@ -37,6 +37,9 @@ module Thrift MISSING_RESULT = 5 INTERNAL_ERROR = 6 PROTOCOL_ERROR = 7 + INVALID_TRANSFORM = 8 + INVALID_PROTOCOL = 9 + UNSUPPORTED_CLIENT_TYPE = 10 attr_reader :type