THRIFT-1801 Sync up TApplicationException codes across languages and thrift implement...
authorRoger Meier <roger@apache.org>
Sat, 22 Dec 2012 20:31:03 +0000 (21:31 +0100)
committerRoger Meier <roger@apache.org>
Sat, 22 Dec 2012 20:31:03 +0000 (21:31 +0100)
Patch: Andrew Cox

20 files changed:
lib/as3/src/org/apache/thrift/TApplicationError.as
lib/c_glib/src/thrift/thrift_application_exception.h
lib/cocoa/src/TApplicationException.h
lib/cocoa/src/TApplicationException.m
lib/cpp/src/thrift/TApplicationException.h
lib/csharp/src/TApplicationException.cs
lib/d/src/thrift/protocol/base.d
lib/delphi/src/Thrift.pas
lib/erl/include/thrift_constants.hrl
lib/go/thrift/tapplication_exception.go
lib/hs/src/Thrift.hs
lib/java/src/org/apache/thrift/TApplicationException.java
lib/javame/src/org/apache/thrift/TApplicationException.java
lib/js/thrift.js
lib/nodejs/lib/thrift/thrift.js
lib/ocaml/src/Thrift.ml
lib/perl/lib/Thrift.pm
lib/php/lib/Thrift/Exception/TApplicationException.php
lib/py/src/Thrift.py
lib/rb/lib/thrift/exceptions.rb

index aa3278d..3448fce 100644 (file)
@@ -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();
index be5a8c0..580f4fc 100644 (file)
@@ -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 */
index 0ad0b9a..7b027d6 100644 (file)
@@ -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
index 66c2f2b..974dfc5 100644 (file)
   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;
index 79f026d..d32a21d 100644 (file)
@@ -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();
index 57dd375..9aaf6f7 100644 (file)
@@ -130,7 +130,12 @@ namespace Thrift
                        InvalidMessageType,
                        WrongMethodName,
                        BadSequenceID,
-                       MissingResult
+                       MissingResult,
+                       InternalError,
+                       ProtocolError,
+                       InvalidTransform,
+                       InvalidProtocol,
+                       UnsupportedClientType
                }
        }
 }
index 97cbb4d..bd65b71 100644 (file)
@@ -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)";
       }
     }
index 189640a..44f12d7 100644 (file)
@@ -43,7 +43,12 @@ type
         InvalidMessageType,
         WrongMethodName,
         BadSequenceID,
-        MissingResult
+        MissingResult,
+        InternalError,
+        ProtocolError,
+        InvalidTransform,
+        InvalidProtocol,
+        UnsupportedClientType
       );
 {$SCOPEDENUMS OFF}
   private
index 61d8e1a..dbfaaf6 100644 (file)
@@ -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).
index fc8bf2e..6b7a75d 100644 (file)
@@ -32,6 +32,9 @@ const (
   MISSING_RESULT                 = 5
   INTERNAL_ERROR                 = 6
   PROTOCOL_ERROR                 = 7
+  INVALID_TRANSFORM              = 8
+  INVALID_PROTOCOL               = 9
+  UNSUPPORTED_CLIENT_TYPE        = 10
 )
 
 
index 42f5d32..65a2208 100644 (file)
@@ -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 )
index c294fc3..b54a5ce 100644 (file)
@@ -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;
 
index de9a162..2f8612a 100644 (file)
@@ -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;
 
index cf89236..39b0a5c 100644 (file)
@@ -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) {
index 6c500a5..94223e3 100644 (file)
@@ -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) {
index 8d423d0..f176a43 100644 (file)
@@ -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)
index f526803..67186f2 100644 (file)
@@ -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;
index 55d46e6..9081973 100644 (file)
@@ -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);
index 707a8cc..9890af7 100644 (file)
@@ -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'
 
index 2ccc7ce..68cb9e0 100644 (file)
@@ -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