Skip to content

Commit 17d7b00

Browse files
committed
deduplicate
1 parent ddeb860 commit 17d7b00

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/Modules/Build.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,8 +1821,7 @@ function buildMode:LoadDB(xmlText, fileName)
18211821
-- Parse the XML
18221822
local dbXML, errMsg = common.xml.ParseXML(xmlText)
18231823
if errMsg and errMsg:match(".*file returns nil") then
1824-
ConPrintf("Error: '%s'", errMsg)
1825-
main:OpenMessagePopup("Cannot read file", '\nMake sure OneDrive is running then restart PoB and try again.\n\n"'..errMsg..'"')
1824+
main:OpenOneDriveErrPopup(fileName)
18261825
return true
18271826
elseif errMsg then
18281827
ConPrintf("Error: '%s'", errMsg)

src/Modules/BuildList.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function listMode:BuildList()
217217
local fileText = fileHnd:read("*a")
218218
fileHnd:close()
219219
if not fileText then
220-
main:OpenMessagePopup("Cannot read file", '\nMake sure OneDrive is running then restart PoB and try again.\n\n"'..build.fullFileName..'"')
220+
main:OpenOneDriveErrPopup(build.fullFileName)
221221
return
222222
end
223223
fileText = fileText:match("(<Build.->)")

src/Modules/Main.lua

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,7 @@ end
519519
function main:LoadSettings(ignoreBuild)
520520
local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml")
521521
if errMsg and errMsg:match(".*file returns nil") then
522-
ConPrintf("Error: '%s'", errMsg)
523-
main:OpenMessagePopup("Cannot read file", '\nMake sure OneDrive is running then restart PoB and try again.\n\n"'..errMsg..'"')
524-
self.saveSettingsOnExit = false
522+
self:OpenOneDriveErrPopup(self.userPath.."Settings.xml")
525523
return true
526524
elseif errMsg and not errMsg:match(".*No such file or directory") then
527525
ConPrintf("Error: '%s'", errMsg)
@@ -665,9 +663,7 @@ end
665663
function main:LoadSharedItems()
666664
local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml")
667665
if errMsg and errMsg:match(".*file returns nil") then
668-
ConPrintf("Error: '%s'", errMsg)
669-
main:OpenMessagePopup("Cannot read file", '\nMake sure OneDrive is running then restart PoB and try again.\n\n"'..errMsg..'"')
670-
self.saveSettingsOnExit = false
666+
self:OpenOneDriveErrPopup(self.userPath.."Settings.xml")
671667
return true
672668
elseif errMsg and not errMsg:match(".*No such file or directory") then
673669
ConPrintf("Error: '%s'", errMsg)
@@ -1569,6 +1565,18 @@ function main:OpenNewFolderPopup(path, onClose)
15691565
main:OpenPopup(370, 100, "New Folder", controls, "create", "edit", "cancel")
15701566
end
15711567

1568+
---Shows a OneDrive-specific error popup
1569+
function main:OpenOneDriveErrPopup(fileName)
1570+
if fileName and fileName ~= "" then
1571+
fileName = "'"..fileName.."'"
1572+
else
1573+
fileName = ""
1574+
end
1575+
ConPrintf("Error: OneDrive: file unreadable: %s", fileName)
1576+
self:OpenMessagePopup(" Cannot read file ", "\nMake sure OneDrive is running then restart "..APP_NAME.." and try again.\n\n"..fileName)
1577+
self.saveSettingsOnExit = false
1578+
end
1579+
15721580
function main:SetWindowTitleSubtext(subtext)
15731581
if not subtext or not self.showTitlebarName then
15741582
SetWindowTitle(APP_NAME)

0 commit comments

Comments
 (0)