Skip to content

Commit 42fbfa1

Browse files
authored
Update adafruit_aws_iot.py
Fixing existing lint issue: W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
1 parent e215002 commit 42fbfa1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

adafruit_aws_iot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)