fix(inferium-harvester): better error handling for fetchRemotePlan

This commit is contained in:
Guillaume ARM 2024-05-21 23:52:09 +02:00
parent 9bd5bbc127
commit b8fb2390f2

View File

@ -280,15 +280,19 @@ local function fetchRemotePlan()
local replyMessage, errMessage = net.sendQuery(INFERIUM_SERVER, message, NETWORK_TIMEOUT)
if replyMessage and replyMessage.payload then
previouslyFetchedRemotePlan = replyMessage.payload
print('> plan fetched')
return replyMessage.payload
elseif previouslyFetchedRemotePlan then
print('> failed to fetch remote plan, use the previous one instead')
print('> failed to fetch: ' .. tostring(errMessage))
print('> use the previous recorded remote plan instead')
return previouslyFetchedRemotePlan
elseif not replyMessage and errMessage then
if lastErrMessage ~= errMessage then
lastErrMessage = errMessage
print('> failed to fetch: ' .. tostring(errMessage))
end
else
error('unknown error during fetch')
end
os.sleep(IDLE_TIME)