添加http错误提示
This commit is contained in:
19
play.lua
19
play.lua
@@ -213,7 +213,7 @@ local initTasks = {}
|
||||
for _, batch in ipairs(initBatches) do
|
||||
table.insert(initTasks, function()
|
||||
while true do
|
||||
local resp = http.post({
|
||||
local resp,http_error = http.post({
|
||||
url = server_url .. "/api/framepack?" .. batch.urls[1],
|
||||
headers = { ["Content-Type"] = "application/json" },
|
||||
body = textutils.serializeJSON({ urls = batch.urls }),
|
||||
@@ -231,10 +231,15 @@ for _, batch in ipairs(initBatches) do
|
||||
allFrameData[globalIdx] = batchFrames[idx]
|
||||
end
|
||||
|
||||
print("Cached init batch: " .. batch.start .. " - " .. (batch.start + #batchFrames - 1))
|
||||
print("[V] Cached init batch: " .. batch.start .. " - " .. (batch.start + #batchFrames - 1))
|
||||
break
|
||||
else
|
||||
print("Retry init batch starting at " .. batch.start)
|
||||
print("[E] " .. batch.start .." "..http_error)
|
||||
|
||||
if http_error == "Response is too large" then
|
||||
error("[E] Frame packet size exceeds 16MB. \nPlease try adjusting the screen size or resolution.")
|
||||
end
|
||||
|
||||
sleep(0.5)
|
||||
end
|
||||
end
|
||||
@@ -345,7 +350,9 @@ local function httpResponseHandler()
|
||||
allFrameData[globalIdx] = batchFrames[idx]
|
||||
end
|
||||
end
|
||||
print("[V] Cached batch: " .. batch.start .. " - " .. (batch.start + #batchFrames - 1))
|
||||
local sizeInMB = #binData / (1024 * 1024)
|
||||
|
||||
print("[V] Cached batch: " .. batch.start .. " - " .. (batch.start + #batchFrames - 1) .." ("..tonumber(string.format("%.1f", sizeInMB)).."Mb)")
|
||||
else
|
||||
print("[R] Unpack failed for batch " .. batch.start .. ": " .. tostring(batchFrames))
|
||||
-- 标记这些帧可重试
|
||||
@@ -361,7 +368,7 @@ local function httpResponseHandler()
|
||||
pendingRequests[url] = nil
|
||||
batch.retry = (batch.retry or 0) + 1
|
||||
if batch.retry < 3 then
|
||||
print("[R] Retrying batch " .. batch.start .. " (attempt " .. (batch.retry + 1) .. ")")
|
||||
print("[R] Retrying batch " .. batch.start .. " (attempt " .. (batch.retry + 1) .. ") Error: "..handleOrErr)
|
||||
-- 允许重试
|
||||
for j = batch.start, batch.start + #batch.urls - 1 do
|
||||
downloadedFrames[j] = nil
|
||||
@@ -369,6 +376,8 @@ local function httpResponseHandler()
|
||||
-- 重新触发 cacheAhead 下一轮会重发
|
||||
else
|
||||
print("[X] Giving up on batch " .. batch.start)
|
||||
print("[E] " .. batch.start.." "..handleOrErr)
|
||||
|
||||
-- 永久失败,不再重试
|
||||
for j = batch.start, batch.start + #batch.urls - 1 do
|
||||
downloadedFrames[j] = true
|
||||
|
||||
Reference in New Issue
Block a user