Starting python exception handling cleanup

Reviewed By: aditya


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665013 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/py/src/protocol/TProtocol.py b/lib/py/src/protocol/TProtocol.py
index 15206b0..e35688e 100644
--- a/lib/py/src/protocol/TProtocol.py
+++ b/lib/py/src/protocol/TProtocol.py
@@ -1,3 +1,5 @@
+from thrift.Thrift import TException
+
 class TType:
   STOP   = 0
   VOID   = 1
@@ -21,6 +23,19 @@
   CALL  = 1
   REPLY = 2
 
+class TProtocolException(TException):
+
+  """Custom Protocol Exception class"""
+
+  UNKNOWN = 0
+  INVALID_DATA = 1
+  NEGATIVE_SIZE = 2
+  SIZE_LIMIT = 3
+
+  def __init__(self, type=UNKNOWN, message=None):
+    TException.__init__(self, message)
+    self.type = type
+
 class TProtocolBase:
 
   """Base class for Thrift protocol driver."""