diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-09-11 14:49:52 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-09-11 14:49:52 +0200 |
commit | 0c8259382f51969ff789a3d2bd341d3f1e0687e0 (patch) | |
tree | 5f08e4583c061516da51c5acdb46c62ff9d6e4e6 /python/vyos/configtree.py | |
parent | bfedcd4c79650414b123fad8158c30fb42ad8fb0 (diff) | |
download | vyos-1x-0c8259382f51969ff789a3d2bd341d3f1e0687e0.tar.gz vyos-1x-0c8259382f51969ff789a3d2bd341d3f1e0687e0.zip |
Add support for retrieving error messages from inside libvyosconfig.
Diffstat (limited to 'python/vyos/configtree.py')
-rw-r--r-- | python/vyos/configtree.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py index 463aa5e95..39fe41669 100644 --- a/python/vyos/configtree.py +++ b/python/vyos/configtree.py @@ -90,6 +90,10 @@ class ConfigTree(object): self.__from_string.argtypes = [c_char_p] self.__from_string.restype = c_void_p + self.__get_error = self.__lib.get_error + self.__get_error.argtypes = [] + self.__get_error.restype = c_char_p + self.__to_string = self.__lib.to_string self.__to_string.argtypes = [c_void_p] self.__to_string.restype = c_char_p @@ -152,10 +156,12 @@ class ConfigTree(object): config_section, comments_section = strip_comments(config_string) config = self.__from_string(config_section.encode()) if config is None: - raise ValueError("Parse error") + msg = self.__get_error().decode() + raise ValueError("Failed to parse config: {0}".format(msg)) else: self.__config = config self.__comments = comments_section + def __del__(self): if self.__config is not None: self.__destroy(self.__config) |