Skip to content

Commit 3b59e7e

Browse files
committed
fix(throttle): enhance error handling for throttle duration parsing
1 parent bf300db commit 3b59e7e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Wippersnapper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,7 @@ void cbThrottleTopic(char *throttleData, uint16_t len) {
17361736
WS_DEBUG_PRINT("IO Throttle Error: ");
17371737
WS_DEBUG_PRINTLNVAR(throttleData);
17381738
uint32_t throttleDuration = 60000UL; // duration of throttle in ms
1739+
bool parsingSuccessful = false;
17391740
if (throttleData != NULL) {
17401741
char *throttleMessage;
17411742
// Parse out # of seconds from message buffer
@@ -1745,9 +1746,14 @@ void cbThrottleTopic(char *throttleData, uint16_t len) {
17451746
if (throttleMessage != NULL) {
17461747
// Convert from seconds to to millis
17471748
throttleDuration = (uint32_t)atoi(throttleMessage) * 1000UL;
1749+
parsingSuccessful = true;
17481750
}
17491751
}
17501752
}
1753+
if (!parsingSuccessful) {
1754+
WS_DEBUG_PRINTLN(
1755+
"ERROR: Unable to parse throttle duration from message, please report this! Defaulting to 60s.");
1756+
}
17511757
WS_DEBUG_PRINT("Device is throttled for ");
17521758
WS_DEBUG_PRINTVAR(throttleDuration);
17531759
WS_DEBUG_PRINTLN("ms and blocking command execution.");

0 commit comments

Comments
 (0)