From 84a456bb58fbae6d4e77f9487a2ba07e23fe102b Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 25 Jun 2025 08:14:54 +0800 Subject: [PATCH] doc/_ext: use raise .. from Use raise-from statement to preserve the root cause of the exception, this helps to provide more context for debugging when the exception is raised. Signed-off-by: Kefu Chai --- doc/_ext/ceph_confval.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/_ext/ceph_confval.py b/doc/_ext/ceph_confval.py index c5e212173f1..f515732bcbb 100644 --- a/doc/_ext/ceph_confval.py +++ b/doc/_ext/ceph_confval.py @@ -84,7 +84,7 @@ TEMPLATE = ''' def eval_size(value) -> int: try: return int(value) - except ValueError: + except ValueError as ex: times = dict(_K=1 << 10, _M=1 << 20, _G=1 << 30, @@ -92,7 +92,7 @@ def eval_size(value) -> int: for unit, m in times.items(): if value.endswith(unit): return int(value[:-len(unit)]) * m - raise ValueError(f'unknown value: {value}') + raise ValueError(f'unknown value: {value}') from ex def readable_duration(value: str, typ: str) -> str: @@ -105,7 +105,7 @@ def readable_duration(value: str, typ: str) -> str: return str(float(value)) else: return str(int(value)) - except ValueError: + except ValueError as ex: times = dict(_min=['minute', 'minutes'], _hr=['hour', 'hours'], _day=['day', 'days']) @@ -114,7 +114,7 @@ def readable_duration(value: str, typ: str) -> str: v = int(value[:-len(unit)]) postfix = readables[0 if v == 1 else 1] return f'{v} {postfix}' - raise ValueError(f'unknown value: {value}') + raise ValueError(f'unknown value: {value}') from ex def do_plain_num(value: str, typ: str) -> str: -- 2.47.3