aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjpakkane <jpakkane@gmail.com>2015-05-03 21:25:47 +0300
committerjpakkane <jpakkane@gmail.com>2015-05-03 21:25:47 +0300
commita4f08e02679cc94068bc02df49fa25ddcc942a8a (patch)
tree0d17262db171b3fd24fb3803ef113b77e65606af
parent4428d9754213af0ad640d3088292814238965f82 (diff)
parentcca29a3383e2346364756de09ea3e579bdc48506 (diff)
downloadmeson-a4f08e02679cc94068bc02df49fa25ddcc942a8a.zip
meson-a4f08e02679cc94068bc02df49fa25ddcc942a8a.tar.gz
meson-a4f08e02679cc94068bc02df49fa25ddcc942a8a.tar.bz2
Merge pull request #103 from afiefh/better_options
Better error messages for user options
-rw-r--r--authors.txt1
-rw-r--r--optinterpreter.py10
2 files changed, 7 insertions, 4 deletions
diff --git a/authors.txt b/authors.txt
index f4213ab..e963f51 100644
--- a/authors.txt
+++ b/authors.txt
@@ -14,4 +14,5 @@ Igor Gnatenko
Hemmo Nieminen
mfrischknecht
Matthew Bekkema
+Afief Halumi
diff --git a/optinterpreter.py b/optinterpreter.py
index df5b111..18a84ad 100644
--- a/optinterpreter.py
+++ b/optinterpreter.py
@@ -51,7 +51,7 @@ class UserStringOption(UserOption):
def set_value(self, newvalue):
if not isinstance(newvalue, str):
- raise OptionException('Value of string option is not a string.')
+ raise OptionException('Value "%s" for string option "%s" is not a string.' % (str(newvalue), self.name))
self.value = newvalue
class UserBooleanOption(UserOption):
@@ -61,7 +61,7 @@ class UserBooleanOption(UserOption):
def set_value(self, newvalue):
if not isinstance(newvalue, bool):
- raise OptionException('Value of boolean option is not boolean.')
+ raise OptionException('Value "%s" for boolean option "%s" is not a boolean.' % (valuestring, self.name))
self.value = newvalue
def parse_string(self, valuestring):
@@ -69,7 +69,7 @@ class UserBooleanOption(UserOption):
return False
if valuestring == 'true':
return True
- raise OptionException('Value %s is not a boolean.' % valuestring)
+ raise OptionException('Value "%s" for boolean option "%s" is not a boolean.' % (valuestring, self.name))
class UserComboOption(UserOption):
def __init__(self, kwargs):
@@ -86,7 +86,8 @@ class UserComboOption(UserOption):
def set_value(self, newvalue):
if newvalue not in self.choices:
- raise OptionException('Combo value must be one of the choices.')
+ optionsstring = ', '.join(['"%s"' % (item,) for item in self.choices])
+ raise OptionException('Value "%s" for combo option "%s" is not one of the choices. Possible choices are: %s.' % (newvalue, self.name, optionsstring))
self.value = newvalue
option_types = {'string' : UserStringOption,
@@ -175,6 +176,7 @@ class OptionInterpreter:
if self.subproject != '':
opt_name = self.subproject + ':' + opt_name
opt = option_types[opt_type](kwargs)
+ opt.name = opt_name
if opt.description == '':
opt.description = opt_name
if opt_name in self.cmd_line_options: