1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 17:59:31 +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. -spec pubsub_item_to_storage_bookmark(#pubsub_item{}) -> {true, bookmark_conference()} | false.
pubsub_item_to_storage_bookmark(#pubsub_item{itemid = {Id, _}, payload = [#xmlel{} = B | _]}) -> pubsub_item_to_storage_bookmark(#pubsub_item{itemid = {Id, _}, payload = [#xmlel{} = B | _]}) ->
try try {xmpp:decode(B), jid:decode(Id)} of
#pep_bookmarks_conference{name = Name, autojoin = AutoJoin, nick = Nick, {#pep_bookmarks_conference{name = Name, autojoin = AutoJoin,
password = Password} = xmpp:decode(B), nick = Nick, password = Password},
#jid{} = Jid = jid:decode(Id), #jid{} = Jid} ->
{true, #bookmark_conference{jid = Jid, name = Name, {true, #bookmark_conference{jid = Jid, name = Name,
autojoin = AutoJoin, nick = Nick, autojoin = AutoJoin, nick = Nick,
password = Password}} password = Password}};
{_, _} ->
false
catch catch
_:{xmpp_codec, Why} -> _:{xmpp_codec, Why} ->
?DEBUG("Failed to decode bookmark element (~ts): ~ts", ?DEBUG("Failed to decode bookmark element (~ts): ~ts",