]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Catch specific exceptions
authorY Bharath <y.bharath@samsung.com>
Thu, 27 Feb 2025 16:01:41 +0000 (21:31 +0530)
committerY Bharath <y.bharath@samsung.com>
Thu, 27 Feb 2025 16:01:41 +0000 (21:31 +0530)
Catch specific exceptions and handle them accordingly

Signed-off-by: y-bharath14 <y.bharath@samsung.com>
tests/topotests/lib/common_check.py

index b04b9de44e89832b0a3263f05b478c40fecc567f..50819c9c708aed121d4c510d68b007f35374eda1 100644 (file)
@@ -19,7 +19,7 @@ def ip_check_path_selection(
         cmdstr = f"show ip route {ipaddr_str} json"
     try:
         output = json.loads(router.vtysh_cmd(cmdstr))
-    except:
+    except (json.JSONDecodeError, ValueError):
         output = {}
 
     ret = topotest.json_cmp(output, expected)
@@ -59,7 +59,7 @@ def iproute2_check_path_selection(router, ipaddr_str, expected, vrf_name=None):
         cmdstr = f"ip -json route show {ipaddr_str}"
     try:
         output = json.loads(router.cmd(cmdstr))
-    except:
+    except (json.JSONDecodeError, ValueError):
         output = []
 
     return topotest.json_cmp(output, expected)