<s> import sys <EOL> from six import u <EOL> from . . version import __version__ , __version_info__ <EOL> from . . exceptions import TwilioException <EOL> class TwilioRestException ( TwilioException ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , status , uri , msg = "<STR_LIT>" , code = None , method = '<STR_LIT:GET>' ) : <EOL> self . uri = uri <EOL> self . status = status <EOL> self . msg = msg <EOL> self . code = code <EOL> self . method = method <EOL> def __str__ ( self ) : <EOL> """<STR_LIT>""" <EOL> def red ( words ) : <EOL> return u ( "<STR_LIT>" ) % words <EOL> def white ( words ) : <EOL> return u ( "<STR_LIT>" ) % words <EOL> def blue ( words ) : <EOL> return u ( "<STR_LIT>" ) % words <EOL> def teal ( words ) : <EOL> return u ( "<STR_LIT>" ) % words <EOL> def get_uri ( code ) : <EOL> return "<STR_LIT>" . format ( code ) <EOL> if hasattr ( sys . stderr , '<STR_LIT>' ) and sys . stderr . isatty ( ) : <EOL> msg = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( <EOL> red_error = red ( "<STR_LIT>" ) , <EOL> request_was = white ( "<STR_LIT>" ) , <EOL> http_line = teal ( "<STR_LIT>" % ( self . method , self . uri ) ) , <EOL> twilio_returned = white ( <EOL> "<STR_LIT>" ) , <EOL> message = blue ( str ( self . msg ) ) <EOL> ) ) <EOL> if self . code : <EOL> msg = "<STR_LIT>" . join ( [ msg , "<STR_LIT>" . format ( <EOL> more_info = white ( "<STR_LIT>" ) , <EOL> uri = blue ( get_uri ( self . code ) ) ) , <EOL> ] ) <EOL> return msg <EOL> else : <EOL> return "<STR_LIT>" . format ( self . status , self . msg ) </s>
