diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index 5ddf54eab8..860135c459 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -160,11 +160,11 @@ local ImportTabClass = newClass("ImportTab", "ControlHost", "Control", function( self.controls.exportFrom:SelByValue(self.exportWebsiteSelected or main.lastExportWebsite or "Pastebin", "id") self.controls.generateCodeByLink = new("ButtonControl", { "LEFT", self.controls.exportFrom, "RIGHT"}, {8, 0, 100, 20}, "Share", function() local exportWebsite = exportWebsitesList[self.controls.exportFrom.selIndex] - local response = buildSites.UploadBuild(self.controls.generateCodeOut.buf, exportWebsite) - if response then + local subScriptId = buildSites.UploadBuild(self.controls.generateCodeOut.buf, exportWebsite) + if subScriptId then self.controls.generateCodeOut:SetText("") self.controls.generateCodeByLink.label = "Creating link..." - launch:RegisterSubScript(response, function(pasteLink, errMsg) + launch:RegisterSubScript(subScriptId, function(pasteLink, errMsg) self.controls.generateCodeByLink.label = "Share" if errMsg then main:OpenMessagePopup(exportWebsite.id, "Error creating link:\n"..errMsg) diff --git a/src/Classes/PoEAPI.lua b/src/Classes/PoEAPI.lua index fe68f4b9af..8fc90874dd 100644 --- a/src/Classes/PoEAPI.lua +++ b/src/Classes/PoEAPI.lua @@ -80,9 +80,9 @@ function PoEAPIClass:FetchAuthToken(callback) if id then launch.subScripts[id] = { type = "DOWNLOAD", - callback = function(code, state, port) + callback = function(code, errMsg, state, port) if not code then - ConPrintf("Failed to get code from server") + ConPrintf("Failed to get code from server: %s", errMsg) self.authToken = nil self.refreshToken = nil self.tokenExpiry = nil diff --git a/src/Launch.lua b/src/Launch.lua index 674e1d85d9..b43e46bd92 100644 --- a/src/Launch.lua +++ b/src/Launch.lua @@ -299,13 +299,13 @@ function launch:DownloadPage(url, callback, params) errMsg = "No data returned" end ConPrintf("Download complete. Status: %s", errMsg or "OK") - return responseHeader, responseBody, errMsg + return responseBody, errMsg, responseHeader ]] local id = LaunchSubScript(script, "", "ConPrintf", url, params.header, params.body, self.connectionProtocol, self.proxyURL) if id then self.subScripts[id] = { type = "DOWNLOAD", - callback = function(responseHeader, responseBody, errMsg) + callback = function(responseBody, errMsg, responseHeader) callback({header=responseHeader, body=responseBody}, errMsg) end } diff --git a/src/LaunchServer.lua b/src/LaunchServer.lua index f5413c6fc5..10152a181d 100644 --- a/src/LaunchServer.lua +++ b/src/LaunchServer.lua @@ -177,6 +177,7 @@ end -- IO, so that it can operate concurrently, but hopefully that isn't necessary. local attempt = 1 local stopAt = os.time() + 30 +local errMsg local shouldRetry, code, state = true, nil, nil while (os.time() < stopAt) and shouldRetry do -- `settimeout`` applies only to individual operations, but we're more concerned with not spending more than 30 @@ -197,4 +198,7 @@ while (os.time() < stopAt) and shouldRetry do attempt = attempt + 1 end server:close() -return code, state, port +if os.time() >= stopAt then + errMsg = "Timeout reached without a response received by the local server" +end +return code, errMsg, state, port