<s> import logging <EOL> import socket <EOL> from django . utils . translation import ugettext as _ <EOL> from django . utils . encoding import smart_str <EOL> LOG = logging . getLogger ( __name__ ) <EOL> def handle_rest_exception ( e , msg ) : <EOL> parent_ex = e . get_parent_ex ( ) <EOL> reason = None <EOL> if hasattr ( parent_ex , '<STR_LIT>' ) : <EOL> reason = parent_ex . reason <EOL> if isinstance ( reason , socket . error ) : <EOL> LOG . error ( smart_str ( '<STR_LIT>' % ( reason [ <NUM_LIT:0> ] , reason [ <NUM_LIT:1> ] ) ) ) <EOL> return { <EOL> '<STR_LIT:status>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : [ _ ( '<STR_LIT>' ) % ( reason [ <NUM_LIT:0> ] , reason [ <NUM_LIT:1> ] ) ] <EOL> } <EOL> else : <EOL> LOG . error ( smart_str ( msg ) ) <EOL> LOG . error ( smart_str ( e . message ) ) <EOL> return { <EOL> '<STR_LIT:status>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : [ msg ] , <EOL> '<STR_LIT>' : str ( e ) <EOL> } </s>
