mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-25 04:54:07 +00:00
Plugin cleanup, and better message distinction
This commit is contained in:
parent
a30937f009
commit
63ea182f94
3 changed files with 13 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ local Promise = require(script.Parent.Parent.modules.Promise)
|
||||||
local Config = require(script.Parent.Config)
|
local Config = require(script.Parent.Config)
|
||||||
local Version = require(script.Parent.Version)
|
local Version = require(script.Parent.Version)
|
||||||
local Http = require(script.Parent.Http)
|
local Http = require(script.Parent.Http)
|
||||||
|
local HttpError = require(script.Parent.HttpError)
|
||||||
|
|
||||||
local ApiContext = {}
|
local ApiContext = {}
|
||||||
ApiContext.__index = ApiContext
|
ApiContext.__index = ApiContext
|
||||||
|
|
@ -104,6 +105,10 @@ function ApiContext:retrieveMessages()
|
||||||
|
|
||||||
return self:retrieveMessages()
|
return self:retrieveMessages()
|
||||||
end, function(err)
|
end, function(err)
|
||||||
|
if err.type == HttpError.Error.Timeout then
|
||||||
|
return self:retrieveMessages()
|
||||||
|
end
|
||||||
|
|
||||||
self.connected = false
|
self.connected = false
|
||||||
|
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ HttpError.Error = {
|
||||||
message = "Rojo plugin couldn't connect to the Rojo server.\n" ..
|
message = "Rojo plugin couldn't connect to the Rojo server.\n" ..
|
||||||
"Make sure the server is running -- use 'Rojo serve' to run it!",
|
"Make sure the server is running -- use 'Rojo serve' to run it!",
|
||||||
},
|
},
|
||||||
|
Timeout = {
|
||||||
|
message = "Rojo timed out during a request.",
|
||||||
|
},
|
||||||
Unknown = {
|
Unknown = {
|
||||||
message = "Rojo encountered an unknown error: {{message}}",
|
message = "Rojo encountered an unknown error: {{message}}",
|
||||||
},
|
},
|
||||||
|
|
@ -44,7 +47,11 @@ function HttpError.fromErrorString(err)
|
||||||
end
|
end
|
||||||
|
|
||||||
if err:find("^curl error") then
|
if err:find("^curl error") then
|
||||||
return HttpError.new(HttpError.Error.ConnectFailed)
|
if err:find("couldn't connect to server") then
|
||||||
|
return HttpError.new(HttpError.Error.ConnectFailed)
|
||||||
|
elseif err:find("timeout was reached") then
|
||||||
|
return HttpError.new(HttpError.Error.Timeout)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return HttpError.new(HttpError.Error.Unknown, err)
|
return HttpError.new(HttpError.Error.Unknown, err)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ function Session.new()
|
||||||
|
|
||||||
for id, instance in pairs(instances) do
|
for id, instance in pairs(instances) do
|
||||||
if id ~= "0" then
|
if id ~= "0" then
|
||||||
print("parent", created[id], created[tostring(instance.parent)])
|
|
||||||
created[id].Parent = created[tostring(instance.parent)]
|
created[id].Parent = created[tostring(instance.parent)]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -57,8 +56,6 @@ function Session.new()
|
||||||
end
|
end
|
||||||
|
|
||||||
api = ApiContext.new(REMOTE_URL, function(message)
|
api = ApiContext.new(REMOTE_URL, function(message)
|
||||||
print("got message", message)
|
|
||||||
|
|
||||||
if message.type == "InstanceChanged" then
|
if message.type == "InstanceChanged" then
|
||||||
print("Instance", message.id, "changed!")
|
print("Instance", message.id, "changed!")
|
||||||
readAll()
|
readAll()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue