Skip to content

Commit

Permalink
fix: better handling JIRA auth error
Browse files Browse the repository at this point in the history
  • Loading branch information
katomaso committed Mar 6, 2024
1 parent e518924 commit 069a63c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gira/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 069a63c

Please sign in to comment.