diff options
author | John Estabrook <jestabro@vyos.io> | 2023-08-09 09:03:28 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-08-09 09:03:28 -0500 |
commit | e4b932ed0a140c9ced9a4eb501d520560b125406 (patch) | |
tree | e9834ad4b9ea9a04f0f89bd98b0b463e14dada65 /python/vyos/configtree.py | |
parent | 9acce7a3c7c87139de291d39c69a90801ac25691 (diff) | |
download | vyos-1x-e4b932ed0a140c9ced9a4eb501d520560b125406.tar.gz vyos-1x-e4b932ed0a140c9ced9a4eb501d520560b125406.zip |
xml: T5452: catch lib errors in generate_cache
Diffstat (limited to 'python/vyos/configtree.py')
-rw-r--r-- | python/vyos/configtree.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index e18d9817d..09cfd43d3 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -383,14 +383,16 @@ def union(left, right, libpath=LIBPATH): return tree def reference_tree_to_json(from_dir, to_file, libpath=LIBPATH): - __lib = cdll.LoadLibrary(libpath) - __reference_tree_to_json = __lib.reference_tree_to_json - __reference_tree_to_json.argtypes = [c_char_p, c_char_p] - __get_error = __lib.get_error - __get_error.argtypes = [] - __get_error.restype = c_char_p - - res = __reference_tree_to_json(from_dir.encode(), to_file.encode()) + try: + __lib = cdll.LoadLibrary(libpath) + __reference_tree_to_json = __lib.reference_tree_to_json + __reference_tree_to_json.argtypes = [c_char_p, c_char_p] + __get_error = __lib.get_error + __get_error.argtypes = [] + __get_error.restype = c_char_p + res = __reference_tree_to_json(from_dir.encode(), to_file.encode()) + except Exception as e: + raise ConfigTreeError(e) if res == 1: msg = __get_error().decode() raise ConfigTreeError(msg) |