THRIFT-2506 Update TProtocolException error codes to be used consistently throughout the library

Patch: Jens Geyer
diff --git a/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as b/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as
index c5788db..9fff730 100644
--- a/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as
+++ b/lib/as3/src/org/apache/thrift/protocol/TProtocolError.as
@@ -29,6 +29,7 @@
     public static const SIZE_LIMIT:int = 3;
     public static const BAD_VERSION:int = 4;
     public static const NOT_IMPLEMENTED:int = 5;
+    public static const DEPTH_LIMIT:int = 6;
   
     public function TProtocolError(error:int = UNKNOWN, message:String = "") {
       super(message, error);
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h b/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h
index df28a4a..58fe5e0 100644
--- a/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h
@@ -328,7 +328,8 @@
   THRIFT_PROTOCOL_ERROR_NEGATIVE_SIZE,
   THRIFT_PROTOCOL_ERROR_SIZE_LIMIT,
   THRIFT_PROTOCOL_ERROR_BAD_VERSION,
-  THRIFT_PROTOCOL_ERROR_NOT_IMPLEMENTED
+  THRIFT_PROTOCOL_ERROR_NOT_IMPLEMENTED,
+  THRIFT_PROTOCOL_ERROR_DEPTH_LIMIT
 } ThriftProtocolError;
 
 /* define an error domain for GError to use */
diff --git a/lib/csharp/src/Protocol/TProtocolException.cs b/lib/csharp/src/Protocol/TProtocolException.cs
index bc002d3..05eb2db 100644
--- a/lib/csharp/src/Protocol/TProtocolException.cs
+++ b/lib/csharp/src/Protocol/TProtocolException.cs
@@ -32,7 +32,8 @@
 		public const int NEGATIVE_SIZE = 2;
 		public const int SIZE_LIMIT = 3;
 		public const int BAD_VERSION = 4;
-		public const int NOT_IMPLEMENTED= 5;
+		public const int NOT_IMPLEMENTED = 5;
+		public const int DEPTH_LIMIT = 6;
 
 		protected int type_ = UNKNOWN;
 
diff --git a/lib/d/src/thrift/protocol/base.d b/lib/d/src/thrift/protocol/base.d
index bd65b71..70648b3 100644
--- a/lib/d/src/thrift/protocol/base.d
+++ b/lib/d/src/thrift/protocol/base.d
@@ -207,7 +207,8 @@
     NEGATIVE_SIZE, ///
     SIZE_LIMIT, ///
     BAD_VERSION, ///
-    NOT_IMPLEMENTED ///
+    NOT_IMPLEMENTED, ///
+    DEPTH_LIMIT ///
   }
 
   ///
@@ -220,6 +221,7 @@
         case Type.SIZE_LIMIT: return "Exceeded size limit";
         case Type.BAD_VERSION: return "Invalid version";
         case Type.NOT_IMPLEMENTED: return "Not implemented";
+        case Type.DEPTH_LIMIT: return "Exceeded size limit";
         default: return "(Invalid exception type)";
       }
     }
diff --git a/lib/delphi/src/Thrift.Protocol.pas b/lib/delphi/src/Thrift.Protocol.pas
index 7ae8e34..4d92cb1 100644
--- a/lib/delphi/src/Thrift.Protocol.pas
+++ b/lib/delphi/src/Thrift.Protocol.pas
@@ -72,13 +72,14 @@
 

   TProtocolException = class( Exception )

   public

-    const

+    const // TODO(jensg): change into enum

       UNKNOWN : Integer = 0;

       INVALID_DATA : Integer = 1;

       NEGATIVE_SIZE : Integer = 2;

       SIZE_LIMIT : Integer = 3;

       BAD_VERSION : Integer = 4;

       NOT_IMPLEMENTED : Integer = 5;

+      DEPTH_LIMIT : Integer = 6;

   protected

     FType : Integer;

   public

diff --git a/lib/go/thrift/protocol_exception.go b/lib/go/thrift/protocol_exception.go
index f1a164a..6e357ee 100644
--- a/lib/go/thrift/protocol_exception.go
+++ b/lib/go/thrift/protocol_exception.go
@@ -36,6 +36,7 @@
 	SIZE_LIMIT                 = 3
 	BAD_VERSION                = 4
 	NOT_IMPLEMENTED            = 5
+	DEPTH_LIMIT                = 6
 )
 
 type tProtocolException struct {
diff --git a/lib/hs/src/Thrift/Protocol.hs b/lib/hs/src/Thrift/Protocol.hs
index f3b342a..6068d16 100644
--- a/lib/hs/src/Thrift/Protocol.hs
+++ b/lib/hs/src/Thrift/Protocol.hs
@@ -188,6 +188,8 @@
     | PE_NEGATIVE_SIZE
     | PE_SIZE_LIMIT
     | PE_BAD_VERSION
+    | PE_NOT_IMPLEMENTED
+    | PE_DEPTH_LIMIT
       deriving ( Eq, Show, Typeable )
 
 data ProtocolExn = ProtocolExn ProtocolExnType String
diff --git a/lib/java/src/org/apache/thrift/protocol/TProtocolException.java b/lib/java/src/org/apache/thrift/protocol/TProtocolException.java
index 248815b..870f1b9 100644
--- a/lib/java/src/org/apache/thrift/protocol/TProtocolException.java
+++ b/lib/java/src/org/apache/thrift/protocol/TProtocolException.java
@@ -35,6 +35,7 @@
   public static final int SIZE_LIMIT = 3;
   public static final int BAD_VERSION = 4;
   public static final int NOT_IMPLEMENTED = 5;
+  public static final int DEPTH_LIMIT = 6;
 
   protected int type_ = UNKNOWN;
 
diff --git a/lib/lua/TProtocol.lua b/lib/lua/TProtocol.lua
index 9eb94f5..616e167 100644
--- a/lib/lua/TProtocol.lua
+++ b/lib/lua/TProtocol.lua
@@ -26,7 +26,7 @@
   SIZE_LIMIT       = 3,
   BAD_VERSION      = 4,
   INVALID_PROTOCOL = 5,
-  MISSING_REQUIRED_FIELD = 6,
+  DEPTH_LIMIT      = 6,
   errorCode        = 0,
   __type = 'TProtocolException'
 }
@@ -41,8 +41,8 @@
     return 'Bad version'
   elseif self.errorCode == self.INVALID_PROTOCOL then
     return 'Invalid protocol'
-  elseif self.errorCode == self.MISSING_REQUIRED_FIELD then
-    return 'Missing required field'
+  elseif self.errorCode == self.DEPTH_LIMIT then
+    return 'Exceeded size limit'
   else
     return 'Default (unknown)'
   end
diff --git a/lib/nodejs/lib/thrift/protocol.js b/lib/nodejs/lib/thrift/protocol.js
index 5e26ff5..3cf3f41 100644
--- a/lib/nodejs/lib/thrift/protocol.js
+++ b/lib/nodejs/lib/thrift/protocol.js
@@ -29,7 +29,9 @@
     INVALID_DATA = 1,
     NEGATIVE_SIZE = 2,
     SIZE_LIMIT = 3,
-    BAD_VERSION = 4;
+    BAD_VERSION = 4,
+    NOT_IMPLEMENTED = 5,
+    DEPTH_LIMIT = 6;
 
 var TProtocolException = function(type, message) {
   Error.call(this, message);
diff --git a/lib/ocaml/src/Thrift.ml b/lib/ocaml/src/Thrift.ml
index f176a43..f0d7a42 100644
--- a/lib/ocaml/src/Thrift.ml
+++ b/lib/ocaml/src/Thrift.ml
@@ -261,6 +261,8 @@
       | NEGATIVE_SIZE
       | SIZE_LIMIT
       | BAD_VERSION
+      | NOT_IMPLEMENTED
+      | DEPTH_LIMIT
 
   exception E of exn_type * string;;
 
diff --git a/lib/perl/lib/Thrift/Protocol.pm b/lib/perl/lib/Thrift/Protocol.pm
index e2801fe..3e9f0dd 100644
--- a/lib/perl/lib/Thrift/Protocol.pm
+++ b/lib/perl/lib/Thrift/Protocol.pm
@@ -34,6 +34,9 @@
 use constant NEGATIVE_SIZE => 2;
 use constant SIZE_LIMIT    => 3;
 use constant BAD_VERSION   => 4;
+use constant NOT_IMPLEMENTED => 5;
+use constant DEPTH_LIMIT   => 6;
+
 
 sub new {
     my $classname = shift;
diff --git a/lib/php/lib/Thrift/Exception/TProtocolException.php b/lib/php/lib/Thrift/Exception/TProtocolException.php
index 98a8d9d..f2529f5 100644
--- a/lib/php/lib/Thrift/Exception/TProtocolException.php
+++ b/lib/php/lib/Thrift/Exception/TProtocolException.php
@@ -41,6 +41,8 @@
   const NEGATIVE_SIZE = 2;
   const SIZE_LIMIT = 3;
   const BAD_VERSION = 4;
+  const NOT_IMPLEMENTED = 5;
+  const DEPTH_LIMIT = 6;
 
   function __construct($message=null, $code=0) {
     parent::__construct($message, $code);
diff --git a/lib/py/src/protocol/TProtocol.py b/lib/py/src/protocol/TProtocol.py
index dc2b095..40e05b1 100644
--- a/lib/py/src/protocol/TProtocol.py
+++ b/lib/py/src/protocol/TProtocol.py
@@ -28,6 +28,8 @@
   NEGATIVE_SIZE = 2
   SIZE_LIMIT = 3
   BAD_VERSION = 4
+  NOT_IMPLEMENTED = 5
+  DEPTH_LIMIT = 6
 
   def __init__(self, type=UNKNOWN, message=None):
     TException.__init__(self, message)
diff --git a/lib/rb/lib/thrift/protocol/base_protocol.rb b/lib/rb/lib/thrift/protocol/base_protocol.rb
index 2869cc8..88f44d4 100644
--- a/lib/rb/lib/thrift/protocol/base_protocol.rb
+++ b/lib/rb/lib/thrift/protocol/base_protocol.rb
@@ -28,6 +28,8 @@
     NEGATIVE_SIZE = 2
     SIZE_LIMIT = 3
     BAD_VERSION = 4
+    NOT_IMPLEMENTED = 5
+    DEPTH_LIMIT = 6
 
     attr_reader :type