Skip to content

Commit

Permalink
refactor: improve error handling for HTTP client errors during firmwa…
Browse files Browse the repository at this point in the history
…re update
  • Loading branch information
SenMorgan committed Dec 8, 2024
1 parent c816a73 commit 8db59d2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/firmware_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ void performFirmwareUpdate(const char *firmwareUrl, PublishResult publishResult)
// Check the HTTP response code
if (httpCode != HTTP_CODE_OK)
{
String details = "HTTP error: " + http.errorToString(httpCode);
// Determine if the error is from the HTTP client and retrieve the error message
String httpClientError = http.errorToString(httpCode);
String details = httpClientError.isEmpty() ? "HTTP request returned: " + String(httpCode) : "HTTP client error: " + httpClientError;
publishResult(false, details.c_str());
// Clean up the HTTP connection
http.end();
return;
}
Expand Down

0 comments on commit 8db59d2

Please sign in to comment.