From 2fb7045248d59cf5277de405fa9429a4bd5536db Mon Sep 17 00:00:00 2001 From: Nightblade Date: Fri, 5 Dec 2025 20:01:54 +1100 Subject: [PATCH 1/2] Add better messaging around cloud files being unavailable --- runtime/lua/xml.lua | 2 +- src/HeadlessWrapper.lua | 9 ++++++- src/Modules/Build.lua | 8 +++--- src/Modules/BuildList.lua | 4 +++ src/Modules/Main.lua | 55 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 68 insertions(+), 10 deletions(-) diff --git a/runtime/lua/xml.lua b/runtime/lua/xml.lua index 6a4c0b2ea5..bfbe00be05 100644 --- a/runtime/lua/xml.lua +++ b/runtime/lua/xml.lua @@ -102,7 +102,7 @@ function xml.LoadXMLFile(fileName) local fileText = fileHnd:read("*a") fileHnd:close() if not fileText then - return nil, fileName.." file returns nil. OneDrive?" + return nil, fileName.." file returns nil" elseif fileText == "" then return nil, fileName.." file is empty" end diff --git a/src/HeadlessWrapper.lua b/src/HeadlessWrapper.lua index 6f7ae1e28a..0ec7d00fdf 100644 --- a/src/HeadlessWrapper.lua +++ b/src/HeadlessWrapper.lua @@ -142,7 +142,7 @@ function PCall(func, ...) return nil, unpack(ret) else return ret[2] - end + end end function ConPrintf(fmt, ...) -- Optional @@ -157,6 +157,13 @@ function SetProfiling(isEnabled) end function Restart() end function Exit() end +---@return string? provider +---@return string? version +---@return number? status +function GetCloudProvider(fullPath) + return nil, nil, nil +end + local l_require = require function require(name) -- Hack to stop it looking for lcurl, which we don't really need diff --git a/src/Modules/Build.lua b/src/Modules/Build.lua index 170a4ccd6d..4dc405056c 100644 --- a/src/Modules/Build.lua +++ b/src/Modules/Build.lua @@ -2157,11 +2157,11 @@ end function buildMode:LoadDB(xmlText, fileName) -- Parse the XML local dbXML, errMsg = common.xml.ParseXML(xmlText) - if not dbXML then - launch:ShowErrMsg("^1Error loading '%s': %s", fileName, errMsg) + if errMsg and errMsg:match(".*file returns nil") then + main:OpenCloudErrorPopup(fileName) return true - elseif #dbXML == 0 then - main:OpenMessagePopup("Error", "Build file is empty, or error parsing xml.\n\n"..fileName) + elseif errMsg then + launch:ShowErrMsg("^1"..errMsg) return true elseif dbXML[1].elem ~= "PathOfBuilding2" then launch:ShowErrMsg("^1Error parsing '%s': 'PathOfBuilding2' root element missing", fileName) diff --git a/src/Modules/BuildList.lua b/src/Modules/BuildList.lua index 3244e5bf25..f0c1ba68e2 100644 --- a/src/Modules/BuildList.lua +++ b/src/Modules/BuildList.lua @@ -216,6 +216,10 @@ function listMode:BuildList() if fileHnd then local fileText = fileHnd:read("*a") fileHnd:close() + if not fileText then + main:OpenCloudErrorPopup(build.fullFileName) + return + end fileText = fileText:match("()") if fileText then local xml = common.xml.ParseXML(fileText.."") diff --git a/src/Modules/Main.lua b/src/Modules/Main.lua index b1cffd4dff..4640694bad 100644 --- a/src/Modules/Main.lua +++ b/src/Modules/Main.lua @@ -106,6 +106,7 @@ function main:Init() self.POESESSID = "" --self.showPublicBuilds = true self.showFlavourText = true + self.errorReadingSettings = false if self.userPath then self:ChangeUserPath(self.userPath, ignoreBuild) @@ -506,9 +507,16 @@ function main:CallMode(func, ...) end function main:LoadSettings(ignoreBuild) + if self.errorReadingSettings then + return true + end local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml") - if errMsg and not errMsg:match(".*No such file or directory") then - ConPrintf("Error: '%s'", errMsg) + if errMsg and errMsg:match(".*file returns nil") then + self.errorReadingSettings = true + self:OpenCloudErrorPopup(self.userPath.."Settings.xml") + return true + elseif errMsg and not errMsg:match(".*No such file or directory") then + self.errorReadingSettings = true launch:ShowErrMsg("^1"..errMsg) return true end @@ -649,9 +657,16 @@ function main:LoadSettings(ignoreBuild) end function main:LoadSharedItems() + if self.errorReadingSettings then + return true + end local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml") - if errMsg and not errMsg:match(".*No such file or directory") then - ConPrintf("Error: '%s'", errMsg) + if errMsg and errMsg:match(".*file returns nil") then + self.errorReadingSettings = true + self:OpenCloudErrorPopup(self.userPath.."Settings.xml") + return true + elseif errMsg and not errMsg:match(".*No such file or directory") then + self.errorReadingSettings = true launch:ShowErrMsg("^1"..errMsg) return true end @@ -697,6 +712,9 @@ function main:LoadSharedItems() end function main:SaveSettings() + if self.errorReadingSettings then + return + end local setXML = { elem = "PathOfBuilding2" } local mode = { elem = "Mode", attrib = { mode = self.mode } } for _, val in ipairs({ self:CallMode("GetArgs") }) do @@ -1546,6 +1564,35 @@ function main:OpenNewFolderPopup(path, onClose) main:OpenPopup(370, 100, "New Folder", controls, "create", "edit", "cancel") end +-- Show an error popup if a file cannot be read due to cloud provider unavailability. +-- Help button opens a URL to PoB's GitHub wiki. +function main:OpenCloudErrorPopup(fileName) + local provider, _, status = GetCloudProvider(fileName) + ConPrintf('Error: file offline "%s" provider: "%s" status: "%s"', + fileName or "?", provider, status) + fileName = fileName and "\n\n^8'"..fileName.."'" or "" + local pobVersion = "^8v"..launch.versionNumber..(launch.versionBranch == "dev" and " (Dev)" or launch.versionBranch == "beta" and " (Beta)" or "") + local title = " Error " + provider = provider or "your cloud provider" + local msg = "\nCannot read file.\n\nMake sure "..provider.." is running then restart "..APP_NAME.." and try again.".. + fileName.."\n\n"..pobVersion + local url = "https://github.com/PathOfBuildingCommunity/PathOfBuilding/wiki/CloudError" + local controls = { } + local numMsgLines = 0 + for line in string.gmatch(msg .. "\n", "([^\n]*)\n") do + t_insert(controls, new("LabelControl", nil, {0, 20 + numMsgLines * 16, 0, 16}, line)) + numMsgLines = numMsgLines + 1 + end + controls.help = new("ButtonControl", nil, {-55, 40 + numMsgLines * 16, 80, 20}, "Help (web)", function() + OpenURL(url) + end) + controls.help.tooltipText = url + controls.close = new("ButtonControl", nil, {55, 40 + numMsgLines * 16, 80, 20}, "Ok", function() + main:ClosePopup() + end) + return self:OpenPopup(m_max(DrawStringWidth(16, "VAR", msg) + 30, 190), 70 + numMsgLines * 16, title, controls, "close") +end + function main:SetWindowTitleSubtext(subtext) if not subtext or not self.showTitlebarName then SetWindowTitle(APP_NAME) From 22a9bce588d117fcf48629651af45b4c4c641e25 Mon Sep 17 00:00:00 2001 From: Nightblade Date: Fri, 5 Dec 2025 20:11:54 +1100 Subject: [PATCH 2/2] Add status number to cloud-error popup --- src/Modules/Main.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Modules/Main.lua b/src/Modules/Main.lua index 4640694bad..e2b465b500 100644 --- a/src/Modules/Main.lua +++ b/src/Modules/Main.lua @@ -1568,14 +1568,14 @@ end -- Help button opens a URL to PoB's GitHub wiki. function main:OpenCloudErrorPopup(fileName) local provider, _, status = GetCloudProvider(fileName) - ConPrintf('Error: file offline "%s" provider: "%s" status: "%s"', - fileName or "?", provider, status) + ConPrintf('^1Error: file offline "%s" provider: "%s" status: "%s"', fileName or "?", provider, status) fileName = fileName and "\n\n^8'"..fileName.."'" or "" - local pobVersion = "^8v"..launch.versionNumber..(launch.versionBranch == "dev" and " (Dev)" or launch.versionBranch == "beta" and " (Beta)" or "") - local title = " Error " + local version = "^8v"..launch.versionNumber..(launch.versionBranch and " "..launch.versionBranch or "")..(launch.devMode and " (dev)" or "") + local title = " ^1Error " provider = provider or "your cloud provider" - local msg = "\nCannot read file.\n\nMake sure "..provider.." is running then restart "..APP_NAME.." and try again.".. - fileName.."\n\n"..pobVersion + local statusText = tostring(status) or "nil" + local msg = "\n^7Cannot read file.\n\nMake sure "..provider.." is running then restart "..APP_NAME.." and try again.".. + fileName.."\nstatus: "..statusText.."\n\n"..version local url = "https://github.com/PathOfBuildingCommunity/PathOfBuilding/wiki/CloudError" local controls = { } local numMsgLines = 0