def __init__(self, code='', args={}): self.code = code for key, value in args.iteritems(): if isinstance(value, unicode): continue # value is not unicode: convert it try: # In case the value formats itself to an ascii string. args[key] = unicode(str(value), 'utf-8') except UnicodeEncodeError: # In case the value is a WokException or it formats # itself to a unicode string. args[key] = unicode(value) # First, check if it is a Wok error message, then search in plugin # error messages list msg = _messages.get(code, code) if (msg == code) and (cherrypy.request.app): msg = self._get_translation() msg = unicode(msg, 'utf-8') % args pattern = "%s: %s" % (code, msg) cherrypy.log.error_log.error(pattern) Exception.__init__(self, pattern)
def __init__(self, code="", args={}): self.code = code for key, value in args.iteritems(): if isinstance(value, unicode): continue # value is not unicode: convert it try: # In case the value formats itself to an ascii string. args[key] = unicode(str(value), "utf-8") except UnicodeEncodeError: # In case the value is a WokException or it formats # itself to a unicode string. args[key] = unicode(value) if cherrypy.request.app: msg = self._get_translation() else: msg = _messages.get(code, code) msg = unicode(msg, "utf-8") % args pattern = "%s: %s" % (code, msg) cherrypy.log.error_log.error(pattern) Exception.__init__(self, pattern)
def __init__(self, code='', args={}): self.code = code for key, value in args.iteritems(): if isinstance(value, unicode): continue # value is not unicode: convert it try: # In case the value formats itself to an ascii string. args[key] = unicode(str(value), 'utf-8') except UnicodeEncodeError: # In case the value is a WokException or it formats # itself to a unicode string. args[key] = unicode(value) if cherrypy.request.app: msg = self._get_translation() else: msg = _messages.get(code, code) msg = unicode(msg, 'utf-8') % args pattern = "%s: %s" % (code, msg) Exception.__init__(self, pattern)