Skip to content

Commit e979cb5

Browse files
authored
Fix subscript errors (#1355)
* Fix various issues with subscript errors * Missed PoEAPI change * Fix errors when returning tables from subscripts
1 parent b58702c commit e979cb5

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ function PoEAPIClass:FetchAuthToken(callback)
8080
if id then
8181
launch.subScripts[id] = {
8282
type = "DOWNLOAD",
83-
callback = function(code, state, port)
83+
callback = function(code, errMsg, state, port)
8484
if not code then
85-
ConPrintf("Failed to get code from server")
85+
ConPrintf("Failed to get code from server: %s", errMsg)
8686
self.authToken = nil
8787
self.refreshToken = nil
8888
self.tokenExpiry = nil

src/Launch.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,13 @@ 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 responseBody, errMsg, responseHeader
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)
308+
callback = function(responseBody, errMsg, responseHeader)
309309
callback({header=responseHeader, body=responseBody}, errMsg)
310310
end
311311
}

src/LaunchServer.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ end
177177
-- IO, so that it can operate concurrently, but hopefully that isn't necessary.
178178
local attempt = 1
179179
local stopAt = os.time() + 30
180+
local errMsg
180181
local shouldRetry, code, state = true, nil, nil
181182
while (os.time() < stopAt) and shouldRetry do
182183
-- `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
197198
attempt = attempt + 1
198199
end
199200
server:close()
200-
return code, state, port
201+
if os.time() >= stopAt then
202+
errMsg = "Timeout reached without a response received by the local server"
203+
end
204+
return code, errMsg, state, port

0 commit comments

Comments
 (0)