From 94031f8ef9b97e36458592b7917542d6681646bd Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Mon, 25 Mar 2024 14:54:53 +0100 Subject: [PATCH] scripts: add error code argument to sendClientError helper And update all users accordingly. This will allow the following commit to use the helper with a different error code. --- src/scripts/lib/linking-utils.lua | 4 ++-- src/scripts/linking/find-defined-target.lua | 2 +- src/scripts/linking/find-filter-target.lua | 2 +- src/scripts/linking/prepare-link.lua | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scripts/lib/linking-utils.lua b/src/scripts/lib/linking-utils.lua index a849828d..8917d715 100644 --- a/src/scripts/lib/linking-utils.lua +++ b/src/scripts/lib/linking-utils.lua @@ -314,7 +314,7 @@ function lutils.haveAvailableRoutes (si_props) return false end -function lutils.sendClientError (event, node, message) +function lutils.sendClientError (event, node, code, message) local source = event:get_source () local client_id = node.properties ["client.id"] if client_id then @@ -323,7 +323,7 @@ function lutils.sendClientError (event, node, message) Constraint { "bound-id", "=", client_id, type = "gobject" } } if client then - client:send_error (node ["bound-id"], -2, message) + client:send_error (node ["bound-id"], code, message) end end end diff --git a/src/scripts/linking/find-defined-target.lua b/src/scripts/linking/find-defined-target.lua index 5028a3a9..e38a67e7 100644 --- a/src/scripts/linking/find-defined-target.lua +++ b/src/scripts/linking/find-defined-target.lua @@ -118,7 +118,7 @@ SimpleEventHook { local linger = cutils.parseBool (si_props ["node.linger"]) if not linger then local node = si:get_associated_proxy ("node") - lutils.sendClientError (event, node, "defined target not found") + lutils.sendClientError (event, node, -2, "defined target not found") node:request_destroy () log:info(si, "... destroyed node as defined target was not found") else diff --git a/src/scripts/linking/find-filter-target.lua b/src/scripts/linking/find-filter-target.lua index c66ef02b..550370c4 100644 --- a/src/scripts/linking/find-filter-target.lua +++ b/src/scripts/linking/find-filter-target.lua @@ -79,7 +79,7 @@ SimpleEventHook { local linger = cutils.parseBool (si_props ["node.linger"]) if not linger then local node = si:get_associated_proxy ("node") - lutils.sendClientError (event, node, "smart filter defined target not found") + lutils.sendClientError (event, node, -2, "smart filter defined target not found") node:request_destroy () log:info(si, "... destroyed node as smart filter defined target was not found") else diff --git a/src/scripts/linking/prepare-link.lua b/src/scripts/linking/prepare-link.lua index 60ed06d2..6a6ccbe1 100644 --- a/src/scripts/linking/prepare-link.lua +++ b/src/scripts/linking/prepare-link.lua @@ -111,7 +111,7 @@ SimpleEventHook { return end - lutils.sendClientError (event, node, + lutils.sendClientError (event, node, -2, reconnect and "no target node available" or "target not found") if not reconnect then