From 49a9702630c8ae4b8ef6e63a08072b8cb6a9fe20 Mon Sep 17 00:00:00 2001 From: Nathan C <39100023+nathanctech@users.noreply.github.com> Date: Thu, 28 May 2020 09:21:42 -0400 Subject: [PATCH] tweak: fix exception if updater breaks Missing nil check can cause exceptions if updater service is unavailable. --- server/main.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/main.lua b/server/main.lua index 59f3a6e..3abd23e 100644 --- a/server/main.lua +++ b/server/main.lua @@ -16,9 +16,8 @@ local VersionAPIRequest = "https://api.kanersps.pw/em/version?version=" .. _VERS function performVersionCheck() print("Performing version check against: " .. VersionAPIRequest .. "\n") PerformHttpRequest(VersionAPIRequest, function(err, rText, headers) - local decoded = json.decode(rText) - - if err == 200 then + if err == 200 and rText ~= nil then + local decoded = json.decode(rText) if(not _FirstCheckPerformed)then print("\n" .. _Prefix .. " Current version: " .. _VERSION) print(_Prefix .. " Updater version: " .. decoded.newVersion .. "\n") @@ -399,4 +398,4 @@ commands["devinfo"].cmd = function(source, args, user) TriggerClientEvent('chatMessage', Source, 'SYSTEM', {255, 0, 0}, "^2[^3EssentialMode^2]^0 Database: ^2 " .. db) TriggerClientEvent('chatMessage', Source, 'SYSTEM', {255, 0, 0}, "^2[^3EssentialMode^2]^0 Logging enabled: ^2 " .. tostring(settings.defaultSettings.enableLogging)) end -commands["devinfo"].callbackfailed = function(source, args, user)end \ No newline at end of file +commands["devinfo"].callbackfailed = function(source, args, user)end