Exemplo n.º 1
0
 def __exit__(self, exctype, excvalue, _exctraceback):
     gcsmsg = '%r' % gcserror.translate_error(excvalue)
     if exctype == GCSError:
         if excvalue in self.__expected:
             debug('expected GCSError %s was raised', gcsmsg)
             return True  # do not re-raise
     if not self.__mustraise and excvalue is None:
         debug('no error was raised')
         return True  # do not re-raise
     expected = ', '.join([gcserror.translate_error(errval) for errval in self.__expected])
     msg = 'expected %s%r but raised was %s' % ('' if self.__mustraise else 'no error or ', expected, gcsmsg)
     raise ValueError(msg)
Exemplo n.º 2
0
 def TranslateError(errval):
     """Translate GCS error number into readable error message.
     @param errval: GCSError value as integer.
     @return: GCSError message as string.
     """
     return gcserror.translate_error(errval)