mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-24 15:13:02 +02:00
Use proper error codes / messages
This commit is contained in:
@@ -80,4 +80,13 @@ std::map<Error, const char*> ErrorNames = {
|
||||
{ Error::NvsGetStatsFailed, "Failed to get setting status" },
|
||||
{ Error::AuthenticationFailed, "Authentication failed!" },
|
||||
{ Error::AnotherInterfaceBusy, "Another interface is busy"},
|
||||
{ Error::FsFailedMount, "Local FS failed mount" },
|
||||
{ Error::FsFailedRead, "Local FS failed read" },
|
||||
{ Error::FsFailedOpenDir, "Local FS failed to open directory" },
|
||||
{ Error::FsDirNotFound, "Local FS directory not found" },
|
||||
{ Error::FsFileEmpty, "Local FS file empty" },
|
||||
{ Error::FsFileNotFound, "Local FS file not found" },
|
||||
{ Error::FsFailedOpenFile, "Local FS failed to open file" },
|
||||
{ Error::FsFailedDelDir, "Local FS failed to delete directory" },
|
||||
{ Error::FsFailedDelFile, "Local FS failed to delete file" },
|
||||
};
|
||||
|
@@ -84,6 +84,15 @@ enum class Error : uint8_t {
|
||||
AuthenticationFailed = 110,
|
||||
Eol = 111,
|
||||
AnotherInterfaceBusy = 120,
|
||||
FsFailedMount = 130, // Local FS Failed to mount
|
||||
FsFailedRead = 131, // Local FS Failed to read file
|
||||
FsFailedOpenDir = 132, // Local FS failed to open directory
|
||||
FsDirNotFound = 133, // Local FS directory not found
|
||||
FsFileEmpty = 134, // Local FS directory not found
|
||||
FsFileNotFound = 135, // Local FS file not found
|
||||
FsFailedOpenFile = 136, // Local FS failed to open file
|
||||
FsFailedDelDir = 138, // Local FS failed to delete dir
|
||||
FsFailedDelFile = 139, // Local FS failed to delete file
|
||||
};
|
||||
|
||||
extern std::map<Error, const char*> ErrorNames;
|
||||
|
@@ -302,11 +302,11 @@ namespace WebUI {
|
||||
}
|
||||
if (!SPIFFS.exists(path)) {
|
||||
webPrintln("Error: No such file!");
|
||||
return Error::SdFileNotFound;
|
||||
return Error::FsFileNotFound;
|
||||
}
|
||||
File currentfile = SPIFFS.open(path, FILE_READ);
|
||||
if (!currentfile) { //if file open success
|
||||
return Error::SdFailedOpenFile;
|
||||
return Error::FsFailedOpenFile;
|
||||
}
|
||||
//until no line in file
|
||||
Error err;
|
||||
@@ -338,11 +338,11 @@ namespace WebUI {
|
||||
}
|
||||
if (!SPIFFS.exists(path)) {
|
||||
webPrintln("Error: No such file!");
|
||||
return Error::SdFileNotFound;
|
||||
return Error::FsFileNotFound;
|
||||
}
|
||||
File currentfile = SPIFFS.open(path, FILE_READ);
|
||||
if (!currentfile) {
|
||||
return Error::SdFailedOpenFile;
|
||||
return Error::FsFailedOpenFile;
|
||||
}
|
||||
while (currentfile.available()) {
|
||||
// String currentline = currentfile.readStringUntil('\n');
|
||||
@@ -810,13 +810,11 @@ namespace WebUI {
|
||||
//char temp_filename[128]; // to help filter by extension TODO: 128 needs a definition based on something
|
||||
File root = fs.open(dirname);
|
||||
if (!root) {
|
||||
//FIXME: need proper error for FS and not usd sd one
|
||||
report_status_message(Error::SdFailedOpenDir, client);
|
||||
report_status_message(Error::FsFailedOpenDir, client);
|
||||
return;
|
||||
}
|
||||
if (!root.isDirectory()) {
|
||||
//FIXME: need proper error for FS and not usd sd one
|
||||
report_status_message(Error::SdDirNotFound, client);
|
||||
report_status_message(Error::FsDirNotFound, client);
|
||||
return;
|
||||
}
|
||||
File file = root.openNextFile();
|
||||
|
Reference in New Issue
Block a user