From: dweatherford Date: Mon, 7 Jan 2008 22:23:07 +0000 (+0000) Subject: [thrift] py: TApplicationException.__str__ X-Git-Tag: 0.2.0~1058 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=33d8f340dcca637e3b91d946f3f6f92daff64456;p=common%2Fthrift.git [thrift] py: TApplicationException.__str__ Summary: Now infinitely more printable than ever before! Reviewed by: mcslee Test Plan: except TApplicationException, inst: \n\t\t print inst Revert: ok git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665414 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/py/src/Thrift.py b/lib/py/src/Thrift.py index aeca9b9e..b8569287 100644 --- a/lib/py/src/Thrift.py +++ b/lib/py/src/Thrift.py @@ -60,6 +60,22 @@ class TApplicationException(TException): TException.__init__(self, message) self.type = type + def __str__(self): + if self.message: + return self.message + elif self.type == UNKNOWN_METHOD: + return 'Unknown method' + elif self.type == INVALID_MESSAGE_TYPE: + return 'Invalid message type' + elif self.type == WRONG_METHOD_NAME: + return 'Wrong method name' + elif self.type == BAD_SEQUENCE_ID: + return 'Bad sequence ID' + elif self.type == MISSING_RESULT: + return 'Missing result' + else: + return 'Default (unknown) TApplicationException' + def read(self, iprot): iprot.readStructBegin() while True: