From 0aa24a31b6a14d2e244d9a7949026e53da90952b Mon Sep 17 00:00:00 2001 From: Pavel Shramov Date: Mon, 23 Dec 2024 11:39:08 +0300 Subject: [PATCH] python: Propogate Config.browse errors --- python/tll/config.pyx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/tll/config.pyx b/python/tll/config.pyx index ea14014c..e6bd9b07 100644 --- a/python/tll/config.pyx +++ b/python/tll/config.pyx @@ -266,12 +266,19 @@ cdef class Config: class appender(list): def __init__(self, sub): self.sub = sub + self.exc = None def __call__(self, k, v): - if v.value() or self.sub: - self.append((k, v.get())) + try: + if v.value() or self.sub: + self.append((k, v.get())) + except Exception as e: + self.exc = (str(k), e) + raise _cb = appender(subpath) if cb is None else cb - tll_config_browse(self._ptr, m, len(m), browse_cb, _cb) + if tll_config_browse(self._ptr, m, len(m), browse_cb, _cb): + if cb is None: + raise RuntimeError(f"Browse failed on key '{_cb.exc[0]}'") from _cb.exc[1] if cb is None: return list(_cb)