Skip to content

Commit

Permalink
Merge pull request #170 from scaarup/error_handling_ugeplaner
Browse files Browse the repository at this point in the history
Add error handling
  • Loading branch information
scaarup authored Jul 22, 2024
2 parents 5e22811 + f79a3be commit 70ab83a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions custom_components/aula/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,16 @@ def ugeplan(week, thisnext):
)
# _LOGGER.debug("ugeplaner status_code "+str(ugeplaner.status_code))
# _LOGGER.debug("ugeplaner response "+str(ugeplaner.text))
for person in ugeplaner.json()["personer"]:
ugeplan = person["institutioner"][0]["ugebreve"][0]["indhold"]
if thisnext == "this":
self.ugep_attr[person["navn"].split()[0]] = ugeplan
elif thisnext == "next":
self.ugepnext_attr[person["navn"].split()[0]] = ugeplan
try:
for person in ugeplaner.json()["personer"]:
ugeplan = person["institutioner"][0]["ugebreve"][0]["indhold"]
if thisnext == "this":
self.ugep_attr[person["navn"].split()[0]] = ugeplan
elif thisnext == "next":
self.ugepnext_attr[person["navn"].split()[0]] = ugeplan
except:
_LOGGER.debug("Cannot fetch ugeplaner, so setting as empty")
_LOGGER.debug("ugeplaner response "+str(ugeplaner.text))

if "0030" in self.widgets:
_LOGGER.debug("In the MU Opgaver flow")
Expand Down

0 comments on commit 70ab83a

Please sign in to comment.