1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 09:49:18 +02:00

mod_private: Improve exception handling

Properly isolate the code that should be subject to exception handling.
This commit is contained in:
Holger Weiss 2025-01-31 14:23:45 +01:00
parent e134d7f0b4
commit 76baf58d5d

View file

@ -447,13 +447,15 @@ pubsub_delete_item(_, _, _, _, _) ->
-spec pubsub_item_to_storage_bookmark(#pubsub_item{}) -> {true, bookmark_conference()} | false.
pubsub_item_to_storage_bookmark(#pubsub_item{itemid = {Id, _}, payload = [#xmlel{} = B | _]}) ->
try
#pep_bookmarks_conference{name = Name, autojoin = AutoJoin, nick = Nick,
password = Password} = xmpp:decode(B),
#jid{} = Jid = jid:decode(Id),
{true, #bookmark_conference{jid = Jid, name = Name,
autojoin = AutoJoin, nick = Nick,
password = Password}}
try {xmpp:decode(B), jid:decode(Id)} of
{#pep_bookmarks_conference{name = Name, autojoin = AutoJoin,
nick = Nick, password = Password},
#jid{} = Jid} ->
{true, #bookmark_conference{jid = Jid, name = Name,
autojoin = AutoJoin, nick = Nick,
password = Password}};
{_, _} ->
false
catch
_:{xmpp_codec, Why} ->
?DEBUG("Failed to decode bookmark element (~ts): ~ts",