mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-25 07:20:52 +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::NvsGetStatsFailed, "Failed to get setting status" },
|
||||||
{ Error::AuthenticationFailed, "Authentication failed!" },
|
{ Error::AuthenticationFailed, "Authentication failed!" },
|
||||||
{ Error::AnotherInterfaceBusy, "Another interface is busy"},
|
{ 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,
|
AuthenticationFailed = 110,
|
||||||
Eol = 111,
|
Eol = 111,
|
||||||
AnotherInterfaceBusy = 120,
|
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;
|
extern std::map<Error, const char*> ErrorNames;
|
||||||
|
@@ -302,11 +302,11 @@ namespace WebUI {
|
|||||||
}
|
}
|
||||||
if (!SPIFFS.exists(path)) {
|
if (!SPIFFS.exists(path)) {
|
||||||
webPrintln("Error: No such file!");
|
webPrintln("Error: No such file!");
|
||||||
return Error::SdFileNotFound;
|
return Error::FsFileNotFound;
|
||||||
}
|
}
|
||||||
File currentfile = SPIFFS.open(path, FILE_READ);
|
File currentfile = SPIFFS.open(path, FILE_READ);
|
||||||
if (!currentfile) { //if file open success
|
if (!currentfile) { //if file open success
|
||||||
return Error::SdFailedOpenFile;
|
return Error::FsFailedOpenFile;
|
||||||
}
|
}
|
||||||
//until no line in file
|
//until no line in file
|
||||||
Error err;
|
Error err;
|
||||||
@@ -338,11 +338,11 @@ namespace WebUI {
|
|||||||
}
|
}
|
||||||
if (!SPIFFS.exists(path)) {
|
if (!SPIFFS.exists(path)) {
|
||||||
webPrintln("Error: No such file!");
|
webPrintln("Error: No such file!");
|
||||||
return Error::SdFileNotFound;
|
return Error::FsFileNotFound;
|
||||||
}
|
}
|
||||||
File currentfile = SPIFFS.open(path, FILE_READ);
|
File currentfile = SPIFFS.open(path, FILE_READ);
|
||||||
if (!currentfile) {
|
if (!currentfile) {
|
||||||
return Error::SdFailedOpenFile;
|
return Error::FsFailedOpenFile;
|
||||||
}
|
}
|
||||||
while (currentfile.available()) {
|
while (currentfile.available()) {
|
||||||
// String currentline = currentfile.readStringUntil('\n');
|
// 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
|
//char temp_filename[128]; // to help filter by extension TODO: 128 needs a definition based on something
|
||||||
File root = fs.open(dirname);
|
File root = fs.open(dirname);
|
||||||
if (!root) {
|
if (!root) {
|
||||||
//FIXME: need proper error for FS and not usd sd one
|
report_status_message(Error::FsFailedOpenDir, client);
|
||||||
report_status_message(Error::SdFailedOpenDir, client);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!root.isDirectory()) {
|
if (!root.isDirectory()) {
|
||||||
//FIXME: need proper error for FS and not usd sd one
|
report_status_message(Error::FsDirNotFound, client);
|
||||||
report_status_message(Error::SdDirNotFound, client);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File file = root.openNextFile();
|
File file = root.openNextFile();
|
||||||
|
Reference in New Issue
Block a user