From 59004b5a068f1fbfe14a359922776c572f78b004 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@41a61cd8-c433-0410-bb1c-e256eeef9e11> Date: Mon, 7 Jan 2008 22:25:40 +0000 Subject: [PATCH] r1447@opsdev009 (orig r76776): dweatherford | 2008-01-07 14:23:07 -0800 [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: http://svn.facebook.com/svnroot/thrift/trunk@742 41a61cd8-c433-0410-bb1c-e256eeef9e11 --- lib/py/src/Thrift.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/py/src/Thrift.py b/lib/py/src/Thrift.py index aeca9b9..b856928 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: -- 2.11.4.GIT