From 20f2034f380cf13b41ad5054a50edef72e18a6c2 Mon Sep 17 00:00:00 2001 From: Giampaolo Lauria Date: Mon, 17 Oct 2011 15:31:30 -0400 Subject: samba-tool: Improve getopt.py error handling Throw an exception when the --option value is invalid --- source4/scripting/python/samba/getopt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py index 14cfba6241..7f500ec63d 100644 --- a/source4/scripting/python/samba/getopt.py +++ b/source4/scripting/python/samba/getopt.py @@ -77,7 +77,11 @@ class SambaOptions(optparse.OptionGroup): if arg.find('=') == -1: raise optparse.OptionValueError("--option option takes a 'a=b' argument") a = arg.split('=') - self._lp.set(a[0], a[1]) + try: + self._lp.set(a[0], a[1]) + except Exception: + raise optparse.OptionValueError("invalid --option option value: %s" + % arg) def get_loadparm(self): """Return loadparm object with data specified on the command line.""" -- cgit