Made cmdsethandler report syntax-errors in a more informative way.
This commit is contained in:
parent
df85edc295
commit
39def4efa9
1 changed files with 9 additions and 6 deletions
|
|
@ -103,7 +103,7 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
python_paths = [path] + ["%s.%s" % (prefix, path)
|
python_paths = [path] + ["%s.%s" % (prefix, path)
|
||||||
for prefix in _CMDSET_PATHS]
|
for prefix in _CMDSET_PATHS if not path.startswith(prefix)]
|
||||||
errstring = ""
|
errstring = ""
|
||||||
for python_path in python_paths:
|
for python_path in python_paths:
|
||||||
try:
|
try:
|
||||||
|
|
@ -123,16 +123,19 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
cmdsetclass = cmdsetclass(cmdsetobj)
|
cmdsetclass = cmdsetclass(cmdsetobj)
|
||||||
return cmdsetclass
|
return cmdsetclass
|
||||||
|
|
||||||
except ImportError:
|
except ImportError, e:
|
||||||
errstring += _("Error loading cmdset: Couldn't import module '%s'.")
|
errstring += _("Error loading cmdset: Couldn't import module '%s': %s.")
|
||||||
errstring = errstring % modulepath
|
errstring = errstring % (modulepath, e)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
errstring += _("Error in loading cmdset: No cmdset class '%(classname)s' in %(modulepath)s.")
|
errstring += _("Error in loading cmdset: No cmdset class '%(classname)s' in %(modulepath)s.")
|
||||||
errstring = errstring % {"classname": classname,
|
errstring = errstring % {"classname": classname,
|
||||||
"modulepath": modulepath}
|
"modulepath": modulepath}
|
||||||
|
except SyntaxError, e:
|
||||||
|
errstring += _("SyntaxError encountered when loading cmdset '%s': %s.")
|
||||||
|
errstring = errstring % (modulepath, e)
|
||||||
except Exception:
|
except Exception:
|
||||||
errstring += _("Compile/Run error when loading cmdset '%s'. Error was logged.")
|
errstring += _("Compile/Run error when loading cmdset '%s': %s.")
|
||||||
errstring = errstring % (python_path)
|
errstring = errstring % (python_path, e)
|
||||||
|
|
||||||
if errstring:
|
if errstring:
|
||||||
# returning an empty error cmdset
|
# returning an empty error cmdset
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue