From aa5faf1f36d2d628c1de1235dc30deb6a36bb16c Mon Sep 17 00:00:00 2001
From: Badlop <badlop@process-one.net>
Date: Tue, 1 Oct 2024 13:23:53 +0200
Subject: [PATCH] mod_privilege: Replace try...catch with a clean alternative

---
 src/mod_privilege.erl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mod_privilege.erl b/src/mod_privilege.erl
index 7524af181..b873fe13f 100644
--- a/src/mod_privilege.erl
+++ b/src/mod_privilege.erl
@@ -391,8 +391,9 @@ code_change(_OldVsn, State, _Extra) ->
 %%%===================================================================
 -spec get_permissions(binary()) -> permissions().
 get_permissions(ServerHost) ->
-    try ets:lookup_element(?MODULE, ServerHost, 2)
-    catch _:badarg -> #{}
+    case ets:lookup(?MODULE, ServerHost) of
+        [] -> #{};
+        [{_, Permissions}] -> Permissions
     end.
 
 -spec forward_message(message()) -> ok.