def TranslateSystemErrors(method):
 def WrappedMethod(self, *args, **kwargs):
  try:
   return method(self, *args, **kwargs)
  except socket.gaierror as e:
   raise apiproxy_errors.ApplicationError(remote_socket_service_pb.RemoteSocketServiceError.GAI_ERROR, ('system_error:%u error_detail:"%s"' % (e.errno, e.strerror)))
  except socket.timeout as e:
   raise apiproxy_errors.ApplicationError(remote_socket_service_pb.RemoteSocketServiceError.SYSTEM_ERROR, ('system_error:%u error_detail:"%s"' % (errno.EAGAIN, os.strerror(errno.EAGAIN))))
  except socket.error as e:
   raise apiproxy_errors.ApplicationError(remote_socket_service_pb.RemoteSocketServiceError.SYSTEM_ERROR, ('system_error:%u error_detail:"%s"' % (e.errno, e.strerror)))
 return WrappedMethod

def TranslateSystemErrors ( method ) : def WrappedMethod ( self , * args , ** kwargs ) : try : return method ( self , * args , ** kwargs ) except socket . gaierror as e : raise apiproxy_errors . ApplicationError ( remote_socket_service_pb . RemoteSocketServiceError . GAI_ERROR , ( 'system_error:%u error_detail:"%s"' % ( e . errno , e . strerror ) ) ) except socket . timeout as e : raise apiproxy_errors . ApplicationError ( remote_socket_service_pb . RemoteSocketServiceError . SYSTEM_ERROR , ( 'system_error:%u error_detail:"%s"' % ( errno . EAGAIN , os . strerror ( errno . EAGAIN ) ) ) ) except socket . error as e : raise apiproxy_errors . ApplicationError ( remote_socket_service_pb . RemoteSocketServiceError . SYSTEM_ERROR , ( 'system_error:%u error_detail:"%s"' % ( e . errno , e . strerror ) ) ) return WrappedMethod
decorator to catch and translate socket .