Skip to content

Commit

Permalink
Catch all KeyError exceptions (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
amelchio authored Aug 18, 2019
1 parent c3ce6a6 commit 615afac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions eternalegypt/eternalegypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ async def set_autoconnect_mode(self, mode):

def _build_information(self, data):
"""Read the bits we need from returned data."""
if 'wwan' not in data:
raise Error()

result = Information()

result.serial_number = data['general']['FSN']
Expand Down Expand Up @@ -269,7 +266,11 @@ async def information(self):
async with self.websession.get(url) as response:
data = json.loads(await response.text())

result = self._build_information(data)
try:
result = self._build_information(data)
except KeyError:
_LOGGER.debug("Failed to read information: %s", data)
raise Error()

self._sms_events(result)

Expand Down

0 comments on commit 615afac

Please sign in to comment.