fix: better error support
This commit is contained in:
parent
5cfa351e67
commit
e6582d6d9d
1 changed files with 12 additions and 1 deletions
|
@ -46,13 +46,19 @@ def _main():
|
||||||
fake_rougail_config = {'step.user_data': 'environment',
|
fake_rougail_config = {'step.user_data': 'environment',
|
||||||
'environment.default_environment_name': 'ROUGAILCLI',
|
'environment.default_environment_name': 'ROUGAILCLI',
|
||||||
}
|
}
|
||||||
UserDatas(cmd_config).user_datas(RougailUserDataEnvironment(cmd_config, rougailconfig=fake_rougail_config).run())
|
user_data = UserDatas(cmd_config).user_datas(RougailUserDataEnvironment(cmd_config, rougailconfig=fake_rougail_config).run())
|
||||||
|
if user_data["errors"]:
|
||||||
|
raise Exception(user_data["errors"][0])
|
||||||
|
if user_data["warnings"]:
|
||||||
|
raise Exception(user_data["warnings"][0])
|
||||||
parser = TiramisuCmdlineParser(
|
parser = TiramisuCmdlineParser(
|
||||||
cmd_config,
|
cmd_config,
|
||||||
add_extra_options=False,
|
add_extra_options=False,
|
||||||
short_name_max_len=2,
|
short_name_max_len=2,
|
||||||
)
|
)
|
||||||
parser.parse_args()
|
parser.parse_args()
|
||||||
|
global print_traceback
|
||||||
|
print_traceback = rougailconfig["cli.debug"]
|
||||||
cmd_config.property.setdefault(origin_prop, 'read_write', 'append')
|
cmd_config.property.setdefault(origin_prop, 'read_write', 'append')
|
||||||
cmd_config.property.remove("not_for_commandline")
|
cmd_config.property.remove("not_for_commandline")
|
||||||
cmd_config.property.read_only()
|
cmd_config.property.read_only()
|
||||||
|
@ -129,8 +135,13 @@ def _main():
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
global print_traceback
|
||||||
|
print_traceback = False
|
||||||
try:
|
try:
|
||||||
_main()
|
_main()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
if print_traceback:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
print(_("ERROR: {0}").format(err))
|
print(_("ERROR: {0}").format(err))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
Loading…
Reference in a new issue