From 0e77f24da30f405ca851fd2cb79d4cb7cc68c173 Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Mon, 29 Apr 2024 19:47:15 +0000 Subject: [PATCH] Improve PaloAltoArp API error handling Even if we do want a broad exception handler, never use just `except`, as that will catch even low-level Python exceptions. Added a noqa tag and log the full exception with a slightly more information message. --- python/nav/ipdevpoll/plugins/paloaltoarp.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/nav/ipdevpoll/plugins/paloaltoarp.py b/python/nav/ipdevpoll/plugins/paloaltoarp.py index 1334b7a8b4..511ec03748 100644 --- a/python/nav/ipdevpoll/plugins/paloaltoarp.py +++ b/python/nav/ipdevpoll/plugins/paloaltoarp.py @@ -117,9 +117,10 @@ def creatorForNetloc(self, hostname, port): ), None, ) - except: - self._logger.info( - "make sure the device is reachable and the key is correct" + except Exception: # noqa + self._logger.exception( + "Error when talking to PaloAlto API. " + "Make sure the device is reachable and the API key is correct." ) returnValue(None)