From 069a63ca9231f35cf45d7159e0d929819e9ad090 Mon Sep 17 00:00:00 2001 From: Tomas Peterka Date: Wed, 6 Mar 2024 12:02:07 +0100 Subject: [PATCH] fix: better handling JIRA auth error --- gira/jira.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gira/jira.py b/gira/jira.py index be9df24..7919758 100644 --- a/gira/jira.py +++ b/gira/jira.py @@ -71,7 +71,7 @@ class Jira: email: Optional[str] projects: list[str] - _client = None + _client: Optional[jira.JIRA] def __init__(self, url: str = "", token: str = "", email: str = "", **kwargs): self.url = url @@ -107,8 +107,10 @@ def update_ticket_details(self, ticket: Ticket) -> Optional[Ticket]: if self._client is None and self._connect_error == 0: try: self.connect() - except Exception as e: - logger.warn(f"Could not connect to Jira: {type(e)}: {e}") + except jira.exceptions.JIRAError as e: + if e.status_code == 401: + raise ConfigError("Invalid Jira credentials") + logger.warn(f"Jira connection error: {e.status_code} - {e.text[:50]}...") self._connect_error += 1 if self._client is not None: