Beispiel #1
0
def XErrorToName(xerror):
    global xerror_to_name
    try:
        if xerror_to_name is None:
            xerror_to_name = {}
            from wimpiggy.lowlevel import const     #@UnresolvedImport
            for name,code in const.items():
                if name=="Success" or name.startswith("Bad"):
                    xerror_to_name[code] = name
            log("XErrorToName(..) initialized error names: %s", xerror_to_name)
        if xerror.message in xerror_to_name:
            return xerror_to_name.get(xerror.message)
    except:
        log.error("XErrorToName", exc_info=True)
    return xerror
Beispiel #2
0
def XErrorToName(xerror):
    global xerror_to_name
    if type(xerror)!=int:
        return xerror
    try:
        from wimpiggy.lowlevel import const, get_error_text     #@UnresolvedImport
        if xerror_to_name is None:
            xerror_to_name = {}
            for name,code in const.items():
                if name=="Success" or name.startswith("Bad"):
                    xerror_to_name[code] = name
            log("XErrorToName(..) initialized error names: %s", xerror_to_name)
        if xerror in xerror_to_name:
            return xerror_to_name.get(xerror)
        return get_error_text(xerror)
    except Exception, e:
        log.error("XErrorToName: %s", e, exc_info=True)