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