def getSafeExString(ex, encoding=None):
 retVal = ex
 if getattr(ex, 'message', None):
  retVal = ex.message
 elif getattr(ex, 'msg', None):
  retVal = ex.msg
 return getUnicode(retVal, encoding=encoding)

def getSafeExString ( ex , encoding = None ) : retVal = ex if getattr ( ex , 'message' , None ) : retVal = ex . message elif getattr ( ex , 'msg' , None ) : retVal = ex . msg return getUnicode ( retVal , encoding = encoding )
safe way how to get the proper exception represtation as a string "%s" % exception and 2) "%s" % str(exception) .