Skip to content

Commit 80a9736

Browse files
committed
print WLED error codes to serial + netdebug
These errors were shown in UI only, but missing in debug output.
1 parent 78741a4 commit 80a9736

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

wled00/json.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,27 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
685685
// USER_PRINTF("serializeState %d\n", netDebugEnabled);
686686
#endif
687687

688+
// WLEDMM print error message to netDebug - esp32 only, as 8266 flash is very limited
689+
#ifdef ARDUINO_ARCH_ESP32
690+
String errPrefix = F("\nWLED error: ");
691+
String warnPrefix = F("WLED warning: ");
692+
switch(errorFlag) {
693+
case ERR_NONE: break;
694+
case ERR_DENIED: USER_PRINTLN(errPrefix + F("Permission denied.")); break;
695+
case ERR_NOBUF: USER_PRINTLN(warnPrefix + F("JSON buffer was not released in time, request timeout.")); break;
696+
case ERR_JSON: USER_PRINTLN(errPrefix + F("JSON parsing failed (input too large?).")); break;
697+
case ERR_FS_BEGIN: USER_PRINTLN(errPrefix + F("Could not init filesystem (no partition?).")); break;
698+
case ERR_FS_QUOTA: USER_PRINTLN(errPrefix + F("FS is full or the maximum file size is reached.")); break;
699+
case ERR_FS_PLOAD: USER_PRINTLN(warnPrefix + F("Tried loading a preset that does not exist.")); break;
700+
case ERR_FS_IRLOAD: USER_PRINTLN(warnPrefix + F("Tried loading an IR JSON cmd, but \"ir.json\" file does not exist.")); break;
701+
case ERR_FS_RMLOAD: USER_PRINTLN(warnPrefix + F("Tried loading a remote JSON cmd, but \"remote.json\" file does not exist.")); break;
702+
case ERR_FS_GENERAL: USER_PRINTLN(errPrefix + F("general unspecified filesystem error.")); break;
703+
default: USER_PRINT(errPrefix + F("error code = ")); USER_PRINTLN(errorFlag); break;
704+
}
705+
#else
706+
if (errorFlag) { USER_PRINT(F("\nWLED error code = ")); USER_PRINTLN(errorFlag); }
707+
#endif
708+
688709
if (errorFlag) {root[F("error")] = errorFlag; errorFlag = ERR_NONE;} //prevent error message to persist on screen
689710

690711
root["ps"] = (currentPreset > 0) ? currentPreset : -1;

wled00/wled.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ pinManager.allocateMultiplePins(pins, sizeof(pins)/sizeof(managed_pin_type), Pin
657657
for (uint8_t i=1; i<WLED_MAX_BUTTONS; i++) btnPin[i] = -1;
658658

659659
bool fsinit = false;
660-
USER_PRINTLN(F("Mount FS"));
660+
USER_PRINTLN(F("Mounting FS ..."));
661661
#ifdef ARDUINO_ARCH_ESP32
662662
fsinit = WLED_FS.begin(true);
663663
#else
@@ -666,6 +666,8 @@ pinManager.allocateMultiplePins(pins, sizeof(pins)/sizeof(managed_pin_type), Pin
666666
if (!fsinit) {
667667
USER_PRINTLN(F("Mount FS failed!")); // WLEDMM
668668
errorFlag = ERR_FS_BEGIN;
669+
} else {
670+
USER_PRINTLN(F("Mount FS succeeded.")); // WLEDMM
669671
}
670672
#ifdef WLED_ADD_EEPROM_SUPPORT
671673
else deEEP();

0 commit comments

Comments
 (0)