diff options
author | AL-LCL <alvin@alvinhavel.com> | 2023-05-19 11:01:49 +0200 |
---|---|---|
committer | AL-LCL <alvin@alvinhavel.com> | 2023-05-19 11:01:49 +0200 |
commit | 20dbeb2f38684c65ff0a4b99012c161295708e88 (patch) | |
tree | a5b8445f55da2fbbb92443b68e9d7354a290c598 /domestic/parse/error_exception_handling.py |
Diffstat (limited to 'domestic/parse/error_exception_handling.py')
-rw-r--r-- | domestic/parse/error_exception_handling.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/domestic/parse/error_exception_handling.py b/domestic/parse/error_exception_handling.py new file mode 100644 index 0000000..286b3c2 --- /dev/null +++ b/domestic/parse/error_exception_handling.py @@ -0,0 +1,41 @@ +from domestic.utility.validate_dict_key import * +from domestic.utility.status_message import * +from domestic.utility.write_error import * +from domestic.globally.get_help import * +from domestic.global_state import * + + +def error_exception_handling(func): + def func_wrapper(*args): + try: + number_of_arguments = len(args) + + if number_of_arguments == 1: + func(args[0]) + elif number_of_arguments == 2: + func(args[0], args[1]) + elif number_of_arguments == 3: + func(args[0], args[1], args[2]) + elif number_of_arguments == 4: + func(args[0], args[1], args[2], args[3]) + elif number_of_arguments == 5: + func(args[0], args[1], args[2], args[3], args[4]) + elif number_of_arguments == 6: + func(args[0], args[1], args[2], args[3], args[4], args[5]) + elif number_of_arguments == 7: + func(args[0], args[1], args[2], args[3], args[4], args[5], args[6]) + except Exception as err: + write_error(err) + + if state['session']['active'] and func.__name__ in [*state['sockets']['modules']]: + func_key = validate_dict_key(help_obj, f'{func.__name__}_2', False) + elif func.__name__ == 'listening': + func_key = validate_dict_key(help_obj, 'listen', False) + else: + func_key = validate_dict_key(help_obj, func.__name__, False) + + if func_key: + status_message(f'An exception was reached, please verify your input & try again\nUsage: {func_key["usage"]}', 'danger') + else: + status_message('Exception was reached, something went wrong\nPlease validate your input & try again', 'danger') + return func_wrapper
\ No newline at end of file |