launcher error messages

This commit is contained in:
seraphima
2024-07-25 15:17:02 +02:00
parent f922f56890
commit 6686c5b5f5
2 changed files with 31 additions and 4 deletions

View File

@@ -117,4 +117,20 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Empty_file" xml:space="preserve">
<value>File {0} is empty.</value>
</data>
<data name="File_reading_error" xml:space="preserve">
<value>Error reading file {0}.</value>
</data>
<data name="Incorrect_file_error" xml:space="preserve">
<value>Incorrect {0} file.</value>
</data>
<data name="Projects" xml:space="preserve">
<value>Projects</value>
<comment>Name of the module</comment>
</data>
<data name="Project_not_found" xml:space="preserve">
<value>Project {0} not found.</value>
</data>
</root>

View File

@@ -4,11 +4,14 @@
#include <AppLauncher.h>
#include <Generated Files/resource.h>
#include <common/utils/elevation.h>
#include <common/utils/gpo.h>
#include <common/utils/logger_helper.h>
#include <common/utils/process_path.h>
#include <common/utils/UnhandledExceptionHandler.h>
#include <common/utils/resources.h>
const std::wstring moduleName = L"Projects\\ProjectsLauncher";
const std::wstring internalPath = L"";
@@ -65,27 +68,33 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
}
else
{
// TODO: show error message
Logger::critical("Incorrect Projects file");
std::wstring formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_INCORRECT_FILE_ERROR), L"projects.json");
MessageBox(NULL, formattedMessage.c_str(), GET_RESOURCE_STRING(IDS_PROJECTS).c_str(), MB_ICONERROR | MB_OK);
return 1;
}
}
else
{
// TODO: show error message
Logger::critical("Incorrect Projects file");
std::wstring formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_INCORRECT_FILE_ERROR), L"projects.json");
MessageBox(NULL, formattedMessage.c_str(), GET_RESOURCE_STRING(IDS_PROJECTS).c_str(), MB_ICONERROR | MB_OK);
return 1;
}
}
catch (std::exception ex)
{
Logger::error("Exception on reading projects: {}", ex.what());
Logger::critical("Exception on reading projects: {}", ex.what());
std::wstring formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_FILE_READING_ERROR), L"projects.json");
MessageBox(NULL, formattedMessage.c_str(), GET_RESOURCE_STRING(IDS_PROJECTS).c_str(), MB_ICONERROR | MB_OK);
return 1;
}
if (projects.empty())
{
Logger::warn("Projects file is empty");
std::wstring formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_EMPTY_FILE), L"projects.json");
MessageBox(NULL, formattedMessage.c_str(), GET_RESOURCE_STRING(IDS_PROJECTS).c_str(), MB_ICONERROR | MB_OK);
return 1;
}
@@ -106,7 +115,9 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
if (projectToLaunch.id.empty())
{
Logger::info(L"Project {} not found", id);
Logger::critical(L"Project {} not found", id);
std::wstring formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_PROJECT_NOT_FOUND), id);
MessageBox(NULL, formattedMessage.c_str(), GET_RESOURCE_STRING(IDS_PROJECTS).c_str(), MB_ICONERROR | MB_OK);
return 1;
}