<s> import sys <EOL> import traceback <EOL> from thrift . transport . TTransport import TTransportException <EOL> class StructuredException ( Exception ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , code , message , data = None , error_code = <NUM_LIT> ) : <EOL> Exception . __init__ ( self , message ) <EOL> self . code = code <EOL> self . message = message <EOL> self . data = data <EOL> self . error_code = error_code <EOL> ( type , value , tb ) = sys . exc_info ( ) <EOL> self . traceback = traceback . extract_tb ( tb ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . message , self . code , repr ( self . data ) ) <EOL> @ property <EOL> def response_data ( self ) : <EOL> return dict ( code = self . code , <EOL> message = self . message , <EOL> data = self . data , <EOL> traceback = self . traceback ) <EOL> class MessageException ( StructuredException ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , msg , filename = None , error_code = <NUM_LIT> ) : <EOL> StructuredException . __init__ ( self , <EOL> code = "<STR_LIT>" , <EOL> message = msg , <EOL> data = dict ( filename = filename ) , <EOL> error_code = error_code ) <EOL> class StructuredThriftTransportException ( StructuredException , TTransportException ) : <EOL> def __init__ ( self , ex , * args , ** kwargs ) : <EOL> kwargs [ '<STR_LIT:data>' ] = ex <EOL> kwargs [ '<STR_LIT:message>' ] = ex . message <EOL> kwargs [ '<STR_LIT:code>' ] = "<STR_LIT>" <EOL> StructuredException . __init__ ( self , * args , ** kwargs ) </s>
