Improve "couldn't open..." error messages by listing target

This commit is contained in:
Robert Müller 2022-08-16 17:35:47 +02:00
parent 12273bd0d6
commit f0b0d4c163
5 changed files with 28 additions and 18 deletions

View file

@ -15,10 +15,13 @@
void CCountryFlags::LoadCountryflagsIndexfile() void CCountryFlags::LoadCountryflagsIndexfile()
{ {
IOHANDLE File = Storage()->OpenFile("countryflags/index.txt", IOFLAG_READ | IOFLAG_SKIP_BOM, IStorage::TYPE_ALL); const char *pFilename = "countryflags/index.txt";
IOHANDLE File = Storage()->OpenFile(pFilename, IOFLAG_READ | IOFLAG_SKIP_BOM, IStorage::TYPE_ALL);
if(!File) if(!File)
{ {
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", "couldn't open index file"); char aBuf[128];
str_format(aBuf, sizeof(aBuf), "couldn't open index file '%s'", pFilename);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf);
return; return;
} }

View file

@ -1260,7 +1260,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
Storage()->CreateFolder("demos", IStorage::TYPE_SAVE); Storage()->CreateFolder("demos", IStorage::TYPE_SAVE);
if(!open_file(aBuf)) if(!open_file(aBuf))
{ {
dbg_msg("menus", "couldn't open file"); dbg_msg("menus", "couldn't open file '%s'", aBuf);
} }
} }

View file

@ -201,7 +201,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
Storage()->GetCompletePath(IStorage::TYPE_SAVE, CONFIG_FILE, aBuf, sizeof(aBuf)); Storage()->GetCompletePath(IStorage::TYPE_SAVE, CONFIG_FILE, aBuf, sizeof(aBuf));
if(!open_file(aBuf)) if(!open_file(aBuf))
{ {
dbg_msg("menus", "couldn't open file"); dbg_msg("menus", "couldn't open file '%s'", aBuf);
} }
} }
@ -216,7 +216,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
Storage()->GetCompletePath(IStorage::TYPE_SAVE, "", aBuf, sizeof(aBuf)); Storage()->GetCompletePath(IStorage::TYPE_SAVE, "", aBuf, sizeof(aBuf));
if(!open_file(aBuf)) if(!open_file(aBuf))
{ {
dbg_msg("menus", "couldn't open file"); dbg_msg("menus", "couldn't open file '%s'", aBuf);
} }
} }
@ -233,7 +233,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
Storage()->CreateFolder("themes", IStorage::TYPE_SAVE); Storage()->CreateFolder("themes", IStorage::TYPE_SAVE);
if(!open_file(aBuf)) if(!open_file(aBuf))
{ {
dbg_msg("menus", "couldn't open file"); dbg_msg("menus", "couldn't open file '%s'", aBuf);
} }
} }
@ -749,9 +749,10 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
static CButtonContainer s_SkinDBDirID; static CButtonContainer s_SkinDBDirID;
if(DoButton_Menu(&s_SkinDBDirID, Localize("Skin Database"), 0, &SkinDB)) if(DoButton_Menu(&s_SkinDBDirID, Localize("Skin Database"), 0, &SkinDB))
{ {
if(!open_link("https://ddnet.tw/skins/")) const char *pLink = "https://ddnet.tw/skins/";
if(!open_link(pLink))
{ {
dbg_msg("menus", "couldn't open link"); dbg_msg("menus", "couldn't open link '%s'", pLink);
} }
} }
@ -766,7 +767,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
Storage()->CreateFolder("skins", IStorage::TYPE_SAVE); Storage()->CreateFolder("skins", IStorage::TYPE_SAVE);
if(!open_file(aBuf)) if(!open_file(aBuf))
{ {
dbg_msg("menus", "couldn't open file"); dbg_msg("menus", "couldn't open file '%s'", aBuf);
} }
} }
@ -1863,10 +1864,13 @@ public:
void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, std::vector<CLanguage> &vLanguages) void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, std::vector<CLanguage> &vLanguages)
{ {
IOHANDLE File = pStorage->OpenFile("languages/index.txt", IOFLAG_READ | IOFLAG_SKIP_BOM, IStorage::TYPE_ALL); const char *pFilename = "languages/index.txt";
IOHANDLE File = pStorage->OpenFile(pFilename, IOFLAG_READ | IOFLAG_SKIP_BOM, IStorage::TYPE_ALL);
if(!File) if(!File)
{ {
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", "couldn't open index file"); char aBuf[128];
str_format(aBuf, sizeof(aBuf), "couldn't open index file '%s'", pFilename);
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf);
return; return;
} }

View file

@ -689,7 +689,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
Storage()->CreateFolder(aBufFull, IStorage::TYPE_SAVE); Storage()->CreateFolder(aBufFull, IStorage::TYPE_SAVE);
if(!open_file(aBuf)) if(!open_file(aBuf))
{ {
dbg_msg("menus", "couldn't open file"); dbg_msg("menus", "couldn't open file '%s'", aBuf);
} }
} }

View file

@ -44,9 +44,10 @@ void CMenus::RenderStartMenu(CUIRect MainView)
static CButtonContainer s_DiscordButton; static CButtonContainer s_DiscordButton;
if(DoButton_Menu(&s_DiscordButton, Localize("Discord"), 0, &Button, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) if(DoButton_Menu(&s_DiscordButton, Localize("Discord"), 0, &Button, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)))
{ {
if(!open_link(Localize("https://ddnet.tw/discord"))) const char *pLink = Localize("https://ddnet.tw/discord");
if(!open_link(pLink))
{ {
dbg_msg("menus", "couldn't open link"); dbg_msg("menus", "couldn't open link '%s'", pLink);
} }
m_DoubleClickIndex = -1; m_DoubleClickIndex = -1;
} }
@ -56,9 +57,10 @@ void CMenus::RenderStartMenu(CUIRect MainView)
static CButtonContainer s_LearnButton; static CButtonContainer s_LearnButton;
if(DoButton_Menu(&s_LearnButton, Localize("Learn"), 0, &Button, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) if(DoButton_Menu(&s_LearnButton, Localize("Learn"), 0, &Button, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)))
{ {
if(!open_link(Localize("https://wiki.ddnet.tw/"))) const char *pLink = Localize("https://wiki.ddnet.tw/");
if(!open_link(pLink))
{ {
dbg_msg("menus", "couldn't open link"); dbg_msg("menus", "couldn't open link '%s'", pLink);
} }
m_DoubleClickIndex = -1; m_DoubleClickIndex = -1;
} }
@ -94,9 +96,10 @@ void CMenus::RenderStartMenu(CUIRect MainView)
static CButtonContainer s_WebsiteButton; static CButtonContainer s_WebsiteButton;
if(DoButton_Menu(&s_WebsiteButton, Localize("Website"), 0, &Button, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) if(DoButton_Menu(&s_WebsiteButton, Localize("Website"), 0, &Button, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)))
{ {
if(!open_link("https://ddnet.tw/")) const char *pLink = "https://ddnet.tw/";
if(!open_link(pLink))
{ {
dbg_msg("menus", "couldn't open link"); dbg_msg("menus", "couldn't open link '%s'", pLink);
} }
m_DoubleClickIndex = -1; m_DoubleClickIndex = -1;
} }