<s> import sys <EOL> class StripeError ( Exception ) : <EOL> def __init__ ( self , message = None , http_body = None , http_status = None , <EOL> json_body = None , headers = None ) : <EOL> super ( StripeError , self ) . __init__ ( message ) <EOL> if http_body and hasattr ( http_body , '<STR_LIT>' ) : <EOL> try : <EOL> http_body = http_body . decode ( '<STR_LIT:utf-8>' ) <EOL> except : <EOL> http_body = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . _message = message <EOL> self . http_body = http_body <EOL> self . http_status = http_status <EOL> self . json_body = json_body <EOL> self . headers = headers or { } <EOL> self . request_id = self . headers . get ( '<STR_LIT>' , None ) <EOL> def __unicode__ ( self ) : <EOL> if self . request_id is not None : <EOL> msg = self . _message or "<STR_LIT>" <EOL> return u"<STR_LIT>" . format ( self . request_id , msg ) <EOL> else : <EOL> return self . _message <EOL> if sys . version_info > ( <NUM_LIT:3> , <NUM_LIT:0> ) : <EOL> def __str__ ( self ) : <EOL> return self . __unicode__ ( ) <EOL> else : <EOL> def __str__ ( self ) : <EOL> return unicode ( self ) . encode ( '<STR_LIT:utf-8>' ) <EOL> class APIError ( StripeError ) : <EOL> pass <EOL> class APIConnectionError ( StripeError ) : <EOL> pass <EOL> class CardError ( StripeError ) : <EOL> def __init__ ( self , message , param , code , http_body = None , <EOL> http_status = None , json_body = None , headers = None ) : <EOL> super ( CardError , self ) . __init__ ( <EOL> message , http_body , http_status , json_body , <EOL> headers ) <EOL> self . param = param <EOL> self . code = code <EOL> class InvalidRequestError ( StripeError ) : <EOL> def __init__ ( self , message , param , http_body = None , <EOL> http_status = None , json_body = None , headers = None ) : <EOL> super ( InvalidRequestError , self ) . __init__ ( <EOL> message , http_body , http_status , json_body , <EOL> headers ) <EOL> self . param = param <EOL> class AuthenticationError ( StripeError ) : <EOL> pass <EOL> class RateLimitError ( StripeError ) : <EOL> pass </s>
