Skip to content

Commit

Permalink
refactor(client/api): show warning when removing invalid zone
Browse files Browse the repository at this point in the history
Rather than throwing an error for calling the remove method on
a nil value, or when indexing Zones when none exist, print a
warning.
  • Loading branch information
thelindat committed Apr 23, 2023
1 parent 5532407 commit 5856b6f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ end

---@param id number
function target.removeZone(id)
Zones[id]:remove()
local zone = Zones?[id]

if not zone then
return warn(('attempted to remove a zone that does not exists (id: %s)'):format(id))
end

zone:remove()
end

---@param target table
Expand Down

0 comments on commit 5856b6f

Please sign in to comment.