Skip to content

Commit d8e3c76

Browse files
committed
ESP8266HTTPUpdate - improve error displaying
1 parent 95d53c3 commit d8e3c76

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525

2626
#include "ESP8266httpUpdate.h"
27+
#include <StreamString.h>
2728

2829
extern "C" uint32_t _SPIFFS_start;
2930
extern "C" uint32_t _SPIFFS_end;
@@ -218,8 +219,12 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha
218219
*/
219220
bool ESP8266HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5, int command) {
220221

222+
StreamString error;
223+
221224
if(!Update.begin(size, command)) {
222-
DEBUG_HTTP_UPDATE("[httpUpdate] Update.begin failed!\n");
225+
Update.printError(error);
226+
error.trim(); // remove line ending
227+
DEBUG_HTTP_UPDATE("[httpUpdate] Update.begin failed! (%s)\n", error.c_str());
223228
return false;
224229
}
225230

@@ -228,12 +233,16 @@ bool ESP8266HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5, int com
228233
}
229234

230235
if(Update.writeStream(in) != size) {
231-
DEBUG_HTTP_UPDATE("[httpUpdate] Update.writeStream failed!\n");
236+
Update.printError(error);
237+
error.trim(); // remove line ending
238+
DEBUG_HTTP_UPDATE("[httpUpdate] Update.writeStream failed! (%s)\n", error.c_str());
232239
return false;
233240
}
234241

235242
if(!Update.end()) {
236-
DEBUG_HTTP_UPDATE("[httpUpdate] Update.end failed!\n");
243+
Update.printError(error);
244+
error.trim(); // remove line ending
245+
DEBUG_HTTP_UPDATE("[httpUpdate] Update.end failed! (%s)\n", error.c_str());
237246
return false;
238247
}
239248

0 commit comments

Comments
 (0)