Skip to content

Commit 601a278

Browse files
authored
Fix various issues with subscript errors (#1345)
* Fix various issues with subscript errors * Missed PoEAPI change
1 parent 334a02b commit 601a278

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/Classes/ImportTab.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ local ImportTabClass = newClass("ImportTab", "ControlHost", "Control", function(
160160
self.controls.exportFrom:SelByValue(self.exportWebsiteSelected or main.lastExportWebsite or "Pastebin", "id")
161161
self.controls.generateCodeByLink = new("ButtonControl", { "LEFT", self.controls.exportFrom, "RIGHT"}, {8, 0, 100, 20}, "Share", function()
162162
local exportWebsite = exportWebsitesList[self.controls.exportFrom.selIndex]
163-
local response = buildSites.UploadBuild(self.controls.generateCodeOut.buf, exportWebsite)
164-
if response then
163+
local subScriptId = buildSites.UploadBuild(self.controls.generateCodeOut.buf, exportWebsite)
164+
if subScriptId then
165165
self.controls.generateCodeOut:SetText("")
166166
self.controls.generateCodeByLink.label = "Creating link..."
167-
launch:RegisterSubScript(response, function(pasteLink, errMsg)
167+
launch:RegisterSubScript(subScriptId, function(pasteLink, errMsg)
168168
self.controls.generateCodeByLink.label = "Share"
169169
if errMsg then
170170
main:OpenMessagePopup(exportWebsite.id, "Error creating link:\n"..errMsg)

src/Classes/PoEAPI.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ function PoEAPIClass:FetchAuthToken(callback)
8080
if id then
8181
launch.subScripts[id] = {
8282
type = "DOWNLOAD",
83-
callback = function(code, state, port)
83+
callback = function(response, errMsg)
84+
local code, state, port = unpack(response or {})
8485
if not code then
85-
ConPrintf("Failed to get code from server")
86+
ConPrintf("Failed to get code from server: %s", errMsg)
8687
self.authToken = nil
8788
self.refreshToken = nil
8889
self.tokenExpiry = nil

src/Launch.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,18 @@ function launch:DownloadPage(url, callback, params)
299299
errMsg = "No data returned"
300300
end
301301
ConPrintf("Download complete. Status: %s", errMsg or "OK")
302-
return responseHeader, responseBody, errMsg
302+
return {responseHeader, responseBody}, errMsg
303303
]]
304304
local id = LaunchSubScript(script, "", "ConPrintf", url, params.header, params.body, self.connectionProtocol, self.proxyURL)
305305
if id then
306306
self.subScripts[id] = {
307307
type = "DOWNLOAD",
308-
callback = function(responseHeader, responseBody, errMsg)
309-
callback({header=responseHeader, body=responseBody}, errMsg)
308+
callback = function(response, errMsg)
309+
if response then
310+
callback({header=response[1], body=response[2]}, errMsg)
311+
else
312+
callback({}, errMsg)
313+
end
310314
end
311315
}
312316
end

src/LaunchServer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ while (os.time() < stopAt) and shouldRetry do
197197
attempt = attempt + 1
198198
end
199199
server:close()
200-
return code, state, port
200+
return {code, state, port}

0 commit comments

Comments
 (0)