Simplify error message

This commit is contained in:
Patrick 2023-08-12 13:45:08 +09:00
parent 9b4805cc19
commit 038c35980b

View File

@ -37,14 +37,16 @@ def magicli(exclude=['main'], help_message=True, glbls=None, argv=None):
try:
function_to_call(*args, **kwargs)
except TypeError as e:
print_error(e)
raise
except TypeError:
pass
# except TypeError as e:
# print_error(e)
# raise
def print_error(e):
print('\x1b[91mError:\x1b[0m ', end='')
print(e)
# def print_error(e):
# print('\x1b[91mError:\x1b[0m ', end='')
# print(e)
def format_args(argv):
@ -58,7 +60,7 @@ def filter_functions(args):
"""
Gets list of functions from the globals variable of a specific module (default: __main__).
"""
return [v for k, v in args.items() if inspect.isfunction(v) and v.__module__ == args['__name__']]
return [v for v in args.values() if inspect.isfunction(v) and v.__module__ == args['__name__']]
def print_help_and_exit(app_name, functions):