Before this case was not covered, and printed a stack trace.

Signed-off-by: Guido Trotter <[email protected]>
---
 lib/cli.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index 547d25e..70ac138 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -699,6 +699,8 @@ def FormatError(err):
                " job submissions until old jobs are archived\n")
   elif isinstance(err, errors.TypeEnforcementError):
     obuf.write("Parameter Error: %s" % msg)
+  elif isinstance(err, errors.ParameterError):
+    obuf.write("Parameter Error: %s" % msg)
   elif isinstance(err, errors.GenericError):
     obuf.write("Unhandled Ganeti error: %s" % msg)
   elif isinstance(err, luxi.NoMasterError):
@@ -745,7 +747,13 @@ def GenericMain(commands, override=None, aliases=None):
   if aliases is None:
     aliases = {}
 
-  func, options, args = _ParseArgs(sys.argv, commands, aliases)
+  try:
+    func, options, args = _ParseArgs(sys.argv, commands, aliases)
+  except errors.ParameterError, err:
+    result, err_msg = FormatError(err)
+    ToStderr(err_msg)
+    return 1
+
   if func is None: # parse error
     return 1
 
-- 
1.5.6.5

Reply via email to