From 05594ecca0818009b9071022d0baaa43ca281934 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Mon, 17 Dec 2018 17:51:25 -0800 Subject: [PATCH] Update timeout detection --- plugin/src/HttpError.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin/src/HttpError.lua b/plugin/src/HttpError.lua index e28bc392..f1b06fc2 100644 --- a/plugin/src/HttpError.lua +++ b/plugin/src/HttpError.lua @@ -15,11 +15,20 @@ HttpError.Error = { message = "Couldn't connect to the Rojo server.\n" .. "Make sure the server is running -- use 'rojo serve' to run it!", }, + Timeout = { + message = "Request timed out.", + }, Unknown = { message = "Unknown error: {{message}}", }, } +setmetatable(HttpError.Error, { + __index = function(_, key) + error(("%q is not a valid member of HttpError.Error"):format(tostring(key)), 2) + end, +}) + function HttpError.new(type, extraMessage) extraMessage = extraMessage or "" local message = type.message:gsub("{{message}}", extraMessage) @@ -48,6 +57,10 @@ function HttpError.fromErrorString(message) return HttpError.new(HttpError.Error.HttpNotEnabled) end + if lower:find("^httperror: timedout") then + return HttpError.new(HttpError.Error.Timeout) + end + if lower:find("^httperror: connectfail") then return HttpError.new(HttpError.Error.ConnectFailed) end