Skip to content

Commit

Permalink
Improve PaloAltoArp API error handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lunkwill42 committed Apr 29, 2024
1 parent 46b8765 commit 0e77f24
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/nav/ipdevpoll/plugins/paloaltoarp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 0e77f24

Please sign in to comment.