Skip to content

Commit

Permalink
Fix error on blank scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hoontee committed Sep 20, 2023
1 parent 0600395 commit 12e6421
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
16 changes: 10 additions & 6 deletions Lync/RobloxPluginSource/Plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ end

local function terminate(errorMessage: string)
connecting = false
error("[Lync] - Terminated: " .. errorMessage, 0)
if connected then
task.spawn(error, "[Lync] - " .. errorMessage, 0)
else
error("[Lync] - Terminated: " .. errorMessage, 0)
end
end

local function lpcall(context: string, func: any, ...): (boolean, any)
Expand Down Expand Up @@ -417,7 +421,7 @@ local function eval(value: any): any
if validateLuaProperty(value[1]) then
return (loadstring("return " .. value[1]) :: any)()
else
terminate(`Security: Lua string [ {value[1]} ] doesn't match the JSON property format`)
terminate(`Lua string [ {value[1]} ] doesn't match the JSON property format`)
return
end
else
Expand Down Expand Up @@ -563,7 +567,7 @@ local function buildPath(path: string)
objects[1].Parent = target
listenForChanges(objects[1])
else
task.spawn(error, `[Lync] - '{data.Path}' cannot contain zero or multiple root Instances`)
terminate(`'{data.Path}' cannot contain zero or multiple root Instances`)
end
end
elseif data.Type == "JSON" or data.Type == "YAML" or data.Type == "TOML" or data.Type == "Excel" then
Expand Down Expand Up @@ -669,11 +673,11 @@ local function buildPath(path: string)
end
end)
else
task.spawn(error, `[Lync] - '{data.TerrainRegion[1]}' cannot contain zero or multiple root Instances`)
terminate(`'{data.TerrainRegion[1]}' cannot contain zero or multiple root Instances`)
end
end
else
task.spawn(error, "[Lync] - Cannot use $terrainRegion property with " .. tostring(target))
terminate("Cannot use $terrainRegion property with " .. tostring(target))
end
end
if data.TerrainMaterialColors then
Expand All @@ -689,7 +693,7 @@ local function buildPath(path: string)
end
end
else
task.spawn(error, "[Lync] - Cannot use $terrainMaterialColors property with " .. tostring(target))
terminate("Cannot use $terrainMaterialColors property with " .. tostring(target))
end
end
end
Expand Down
9 changes: 2 additions & 7 deletions Lync/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1365,13 +1365,8 @@ async function changedJson() {
read = JSON.stringify(entries)
}

if (read) {
res.writeHead(200)
res.end(read)
} else {
res.writeHead(403)
res.end('Invalid read')
}
res.writeHead(200)
res.end(read)
} catch (err) {
console.error(red('Server error:'), err)
res.writeHead(500)
Expand Down

0 comments on commit 12e6421

Please sign in to comment.