Skip to content
Snippets Groups Projects
Commit e2e521d0 authored by Iustin Pop's avatar Iustin Pop
Browse files

Small cleanup for error formatting

Reviewed-by: ultrotter
parent c7b46d59
No related branches found
No related tags found
No related merge requests found
...@@ -370,10 +370,11 @@ def FormatError(err): ...@@ -370,10 +370,11 @@ def FormatError(err):
""" """
retcode = 1 retcode = 1
obuf = StringIO() obuf = StringIO()
msg = str(err)
if isinstance(err, errors.ConfigurationError): if isinstance(err, errors.ConfigurationError):
msg = "Corrupt configuration file: %s" % err txt = "Corrupt configuration file: %s" % msg
logger.Error(msg) logger.Error(txt)
obuf.write(msg + "\n") obuf.write(txt + "\n")
obuf.write("Aborting.") obuf.write("Aborting.")
retcode = 2 retcode = 2
elif isinstance(err, errors.HooksAbort): elif isinstance(err, errors.HooksAbort):
...@@ -386,7 +387,7 @@ def FormatError(err): ...@@ -386,7 +387,7 @@ def FormatError(err):
obuf.write(" node: %s, script: %s (no output)\n" % obuf.write(" node: %s, script: %s (no output)\n" %
(node, script)) (node, script))
elif isinstance(err, errors.HooksFailure): elif isinstance(err, errors.HooksFailure):
obuf.write("Failure: hooks general failure: %s" % str(err)) obuf.write("Failure: hooks general failure: %s" % msg)
elif isinstance(err, errors.ResolverError): elif isinstance(err, errors.ResolverError):
this_host = utils.HostInfo.SysName() this_host = utils.HostInfo.SysName()
if err.args[0] == this_host: if err.args[0] == this_host:
...@@ -396,15 +397,15 @@ def FormatError(err): ...@@ -396,15 +397,15 @@ def FormatError(err):
obuf.write(msg % err.args[0]) obuf.write(msg % err.args[0])
elif isinstance(err, errors.OpPrereqError): elif isinstance(err, errors.OpPrereqError):
obuf.write("Failure: prerequisites not met for this" obuf.write("Failure: prerequisites not met for this"
" operation:\n%s" % str(err)) " operation:\n%s" % msg)
elif isinstance(err, errors.OpExecError): elif isinstance(err, errors.OpExecError):
obuf.write("Failure: command execution error:\n%s" % str(err)) obuf.write("Failure: command execution error:\n%s" % msg)
elif isinstance(err, errors.TagError): elif isinstance(err, errors.TagError):
obuf.write("Failure: invalid tag(s) given:\n%s" % str(err)) obuf.write("Failure: invalid tag(s) given:\n%s" % msg)
elif isinstance(err, errors.GenericError): elif isinstance(err, errors.GenericError):
obuf.write("Unhandled Ganeti error: %s" % str(err)) obuf.write("Unhandled Ganeti error: %s" % msg)
else: else:
obuf.write("Unhandled exception: %s" % str(err)) obuf.write("Unhandled exception: %s" % msg)
return retcode, obuf.getvalue().rstrip('\n') return retcode, obuf.getvalue().rstrip('\n')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment