bugfixes (removing GeneralError)

This commit is contained in:
Overwatch 2014-08-19 11:01:49 +02:00
parent fe334e4b07
commit 6416b66f6e

View file

@ -380,19 +380,23 @@ class Main:
for option in self.options: for option in self.options:
if name == option.name: if name == option.name:
self._print("option §B--§r%s§/ already exists" %(name), prefix.fail, exc=GeneralError) self._print("option §B--§r%s§/ already exists" %(name), prefix.fail)
raise RuntimeError
if option.short_name and short_name == option.short_name: if option.short_name and short_name == option.short_name:
self._print("option §B--§r%s§/'s short name §r%s§/ is already taken by §B--§y%s§/" %(name, short_name, option.name), prefix.fail, exc=GeneralError) self._print("option §B--§r%s§/'s short name §r%s§/ is already taken by §B--§y%s§/" %(name, short_name, option.name), prefix.fail)
raise RuntimeError
if short_name and len(short_name) > 1: if short_name and len(short_name) > 1:
self._print("short name must be a single character; option §B--§r%s§/ has §r%s§/"%(name, short_name), prefix.fail, exc=GeneralError) self._print("short name must be a single character; option §B--§r%s§/ has §r%s§/"%(name, short_name), prefix.fail)
raise RuntimeError
if callback: if callback:
use_cfg_file = False use_cfg_file = False
if dtype not in ["bool", "str", "int", "float"]: if dtype not in ["bool", "str", "int", "float"]:
self._print("option §B--§r%s§/'s dtype is not of a supported type" %(name), prefix.fail, exc=GeneralError) self._print("option §B--§r%s§/'s dtype is not of a supported type" %(name), prefix.fail)
raise RuntimeError
v = _verify_type(default, dtype, plural) v = _verify_type(default, dtype, plural)
@ -405,7 +409,8 @@ class Main:
else: else:
type_desc = "a %s" %(dtype) type_desc = "a %s" %(dtype)
self._print("option §B--§r%s§/'s default must be §y%s§/" %(name, type_desc), prefix.fail, exc=GeneralError) self._print("option §B--§r%s§/'s default must be §y%s§/" %(name, type_desc), prefix.fail)
raise RuntimeError
o = Option(name, dtype, default, description, short_name, plural, use_cfg_file, callback, hidden) o = Option(name, dtype, default, description, short_name, plural, use_cfg_file, callback, hidden)
self.options.append(o) self.options.append(o)
@ -478,13 +483,15 @@ class Main:
o.value = bool_on o.value = bool_on
else: else:
if not bool_on: if not bool_on:
self._print("§B--no-§r%s§/ makes no sense because this option is of type §y%s§/" %(name, o.dtype), prefix.fail, exc=GeneralError) self._print("§B--no-§r%s§/ makes no sense because this option is of type §y%s§/" %(name, o.dtype), prefix.fail)
raise RuntimeError
# This option takes arguments. These are all words at ptr and higher that don't begin with "--". # This option takes arguments. These are all words at ptr and higher that don't begin with "--".
# If this option is part of a shortgroup it must be at its end. # If this option is part of a shortgroup it must be at its end.
if to_parse.index(w) + 1 != len(to_parse): if to_parse.index(w) + 1 != len(to_parse):
self._print("option §B{0[0]}§r{1.short_name}§/ needs to be at the end of group §y{0}§/".format(word, o), prefix.fail, exc=GeneralError) self._print("option §B{0[0]}§r{1.short_name}§/ needs to be at the end of group §y{0}§/".format(word, o), prefix.fail)
raise RuntimeError
got_something = False got_something = False