Skip to content

Commit 9970ddc

Browse files
authored
Merge pull request #14 from mpechner/master
Update adafruit_aws_iot.py
2 parents ab2fbf9 + 42fbfa1 commit 9970ddc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

adafruit_aws_iot.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
4242
"""
4343
import json
44-
from adafruit_minimqtt import MMQTTException
44+
from adafruit_minimqtt.adafruit_minimqtt import MMQTTException
4545

4646
__version__ = "0.0.0-auto.0"
4747
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_AWS_IOT.git"
@@ -77,11 +77,11 @@ def __init__(self, mmqttclient, keep_alive=30):
7777
assert (
7878
self.cid[0] != "$"
7979
), "Client ID can not start with restricted client ID prefix $."
80-
except:
80+
except Exception as ex:
8181
raise TypeError(
8282
"You must provide MiniMQTT with your AWS IoT Device's Identifier \
8383
as the Client ID."
84-
)
84+
) from ex
8585
# Shadow-interaction topic
8686
self.shadow_topic = "$aws/things/{}/shadow".format(self.cid)
8787
# keep_alive timer must be between 30 <= keep alive interval <= 1200 seconds
@@ -125,7 +125,7 @@ def disconnect(self):
125125
try:
126126
self.client.disconnect()
127127
except MMQTTException as error:
128-
raise AWS_IOT_ERROR("Error disconnecting with AWS IoT: ", error)
128+
raise AWS_IOT_ERROR("Error disconnecting with AWS IoT: ", error) from error
129129
self.connected_to_aws = False
130130
# Reset user-defined callback methods to None
131131
self.on_connect = None
@@ -142,7 +142,7 @@ def reconnect(self):
142142
try:
143143
self.client.reconnect()
144144
except MMQTTException as error:
145-
raise AWS_IOT_ERROR("Error re-connecting to AWS IoT:", error)
145+
raise AWS_IOT_ERROR("Error re-connecting to AWS IoT:", error) from error
146146

147147
def connect(self, clean_session=True):
148148
"""Connects to Amazon AWS IoT MQTT Broker with Client ID.
@@ -152,7 +152,7 @@ def connect(self, clean_session=True):
152152
try:
153153
self.client.connect(clean_session)
154154
except MMQTTException as error:
155-
raise AWS_IOT_ERROR("Error connecting to AWS IoT: ", error)
155+
raise AWS_IOT_ERROR("Error connecting to AWS IoT: ", error) from error
156156
self.connected_to_aws = True
157157

158158
# MiniMQTT Callback Handlers

0 commit comments

Comments
 (0)