mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Get rid of 'catch-all' statements
This commit is contained in:
parent
43498b39c1
commit
1d80addb7d
@ -585,7 +585,7 @@ handle_sync_event({muc_unsubscribe, From}, _From, StateName, StateData) ->
|
|||||||
handle_sync_event({is_subscribed, From}, _From, StateName, StateData) ->
|
handle_sync_event({is_subscribed, From}, _From, StateName, StateData) ->
|
||||||
IsSubs = try maps:get(jid:split(From), StateData#state.subscribers) of
|
IsSubs = try maps:get(jid:split(From), StateData#state.subscribers) of
|
||||||
#subscriber{nodes = Nodes} -> {true, Nodes}
|
#subscriber{nodes = Nodes} -> {true, Nodes}
|
||||||
catch _:_ -> false
|
catch _:{badkey, _} -> false
|
||||||
end,
|
end,
|
||||||
{reply, IsSubs, StateName, StateData};
|
{reply, IsSubs, StateName, StateData};
|
||||||
handle_sync_event(_Event, _From, StateName,
|
handle_sync_event(_Event, _From, StateName,
|
||||||
@ -979,12 +979,12 @@ get_participant_data(From, StateData) ->
|
|||||||
try maps:get(jid:tolower(From), StateData#state.users) of
|
try maps:get(jid:tolower(From), StateData#state.users) of
|
||||||
#user{nick = FromNick, role = Role} ->
|
#user{nick = FromNick, role = Role} ->
|
||||||
{FromNick, Role}
|
{FromNick, Role}
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
try maps:get(jid:tolower(jid:remove_resource(From)),
|
try maps:get(jid:tolower(jid:remove_resource(From)),
|
||||||
StateData#state.subscribers) of
|
StateData#state.subscribers) of
|
||||||
#subscriber{nick = FromNick} ->
|
#subscriber{nick = FromNick} ->
|
||||||
{FromNick, none}
|
{FromNick, none}
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
{<<"">>, moderator}
|
{<<"">>, moderator}
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
@ -1357,16 +1357,16 @@ do_get_affiliation(JID, StateData) ->
|
|||||||
do_get_affiliation_fallback(JID, StateData) ->
|
do_get_affiliation_fallback(JID, StateData) ->
|
||||||
LJID = jid:tolower(JID),
|
LJID = jid:tolower(JID),
|
||||||
try maps:get(LJID, StateData#state.affiliations)
|
try maps:get(LJID, StateData#state.affiliations)
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
BareLJID = jid:remove_resource(LJID),
|
BareLJID = jid:remove_resource(LJID),
|
||||||
try maps:get(BareLJID, StateData#state.affiliations)
|
try maps:get(BareLJID, StateData#state.affiliations)
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
DomainLJID = setelement(1, LJID, <<"">>),
|
DomainLJID = setelement(1, LJID, <<"">>),
|
||||||
try maps:get(DomainLJID, StateData#state.affiliations)
|
try maps:get(DomainLJID, StateData#state.affiliations)
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
DomainBareLJID = jid:remove_resource(DomainLJID),
|
DomainBareLJID = jid:remove_resource(DomainLJID),
|
||||||
try maps:get(DomainBareLJID, StateData#state.affiliations)
|
try maps:get(DomainBareLJID, StateData#state.affiliations)
|
||||||
catch _:_ -> none
|
catch _:{badkey, _} -> none
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1428,7 +1428,7 @@ set_role(JID, Role, StateData) ->
|
|||||||
NewNs = try maps:get(J, Us) of
|
NewNs = try maps:get(J, Us) of
|
||||||
#user{nick = Nick} ->
|
#user{nick = Nick} ->
|
||||||
maps:remove(Nick, Ns)
|
maps:remove(Nick, Ns)
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
Ns
|
Ns
|
||||||
end,
|
end,
|
||||||
{maps:remove(J, Us), NewNs}
|
{maps:remove(J, Us), NewNs}
|
||||||
@ -1453,7 +1453,7 @@ get_role(JID, StateData) ->
|
|||||||
LJID = jid:tolower(JID),
|
LJID = jid:tolower(JID),
|
||||||
try maps:get(LJID, StateData#state.users) of
|
try maps:get(LJID, StateData#state.users) of
|
||||||
#user{role = Role} -> Role
|
#user{role = Role} -> Role
|
||||||
catch _:_ -> none
|
catch _:{badkey, _} -> none
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_default_role(affiliation(), state()) -> role().
|
-spec get_default_role(affiliation(), state()) -> role().
|
||||||
@ -1647,7 +1647,7 @@ update_online_user(JID, #user{nick = Nick} = User, StateData) ->
|
|||||||
LJIDs ->
|
LJIDs ->
|
||||||
maps:put(OldNick, LJIDs, StateData#state.nicks)
|
maps:put(OldNick, LJIDs, StateData#state.nicks)
|
||||||
end
|
end
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
StateData#state.nicks
|
StateData#state.nicks
|
||||||
end,
|
end,
|
||||||
Nicks = maps:update_with(Nick,
|
Nicks = maps:update_with(Nick,
|
||||||
@ -1709,7 +1709,7 @@ remove_online_user(JID, StateData, Reason) ->
|
|||||||
maps:remove(Nick, StateData#state.nicks);
|
maps:remove(Nick, StateData#state.nicks);
|
||||||
U ->
|
U ->
|
||||||
maps:put(Nick, U -- [LJID], StateData#state.nicks)
|
maps:put(Nick, U -- [LJID], StateData#state.nicks)
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
StateData#state.nicks
|
StateData#state.nicks
|
||||||
end,
|
end,
|
||||||
StateData#state{users = Users, nicks = Nicks}.
|
StateData#state{users = Users, nicks = Nicks}.
|
||||||
@ -1780,7 +1780,7 @@ find_jid_by_nick(Nick, StateData) ->
|
|||||||
end
|
end
|
||||||
end, {FirstUser, FirstPresence}, Users),
|
end, {FirstUser, FirstPresence}, Users),
|
||||||
jid:make(LJID)
|
jid:make(LJID)
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
false
|
false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -1822,7 +1822,7 @@ nick_collision(User, Nick, StateData) ->
|
|||||||
false ->
|
false ->
|
||||||
try maps:get(Nick, StateData#state.subscriber_nicks) of
|
try maps:get(Nick, StateData#state.subscriber_nicks) of
|
||||||
[J] -> J
|
[J] -> J
|
||||||
catch _:_ -> false
|
catch _:{badkey, _} -> false
|
||||||
end;
|
end;
|
||||||
J -> J
|
J -> J
|
||||||
end,
|
end,
|
||||||
@ -3099,7 +3099,7 @@ get_actor_nick(undefined, _StateData) ->
|
|||||||
get_actor_nick(MJID, StateData) ->
|
get_actor_nick(MJID, StateData) ->
|
||||||
try maps:get(jid:tolower(MJID), StateData#state.users) of
|
try maps:get(jid:tolower(MJID), StateData#state.users) of
|
||||||
#user{nick = ActorNick} -> ActorNick
|
#user{nick = ActorNick} -> ActorNick
|
||||||
catch _:_ -> <<"">>
|
catch _:{badkey, _} -> <<"">>
|
||||||
end.
|
end.
|
||||||
|
|
||||||
convert_legacy_fields(Fs) ->
|
convert_legacy_fields(Fs) ->
|
||||||
@ -3992,7 +3992,7 @@ process_iq_mucsub(From,
|
|||||||
Nodes = get_subscription_nodes(Packet),
|
Nodes = get_subscription_nodes(Packet),
|
||||||
NewStateData = set_subscriber(From, Nick, Nodes, StateData),
|
NewStateData = set_subscriber(From, Nick, Nodes, StateData),
|
||||||
{result, subscribe_result(Packet), NewStateData}
|
{result, subscribe_result(Packet), NewStateData}
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
SD2 = StateData#state{config = (StateData#state.config)#config{allow_subscription = true}},
|
SD2 = StateData#state{config = (StateData#state.config)#config{allow_subscription = true}},
|
||||||
add_new_user(From, Nick, Packet, SD2)
|
add_new_user(From, Nick, Packet, SD2)
|
||||||
end;
|
end;
|
||||||
@ -4026,7 +4026,7 @@ process_iq_mucsub(From, #iq{type = set, sub_els = [#muc_unsubscribe{}]},
|
|||||||
{next_state, normal_state, SD} -> SD
|
{next_state, normal_state, SD} -> SD
|
||||||
end,
|
end,
|
||||||
{result, undefined, NewStateData2}
|
{result, undefined, NewStateData2}
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
{result, undefined, StateData}
|
{result, undefined, StateData}
|
||||||
end;
|
end;
|
||||||
process_iq_mucsub(From, #iq{type = get, lang = Lang,
|
process_iq_mucsub(From, #iq{type = get, lang = Lang,
|
||||||
@ -4357,7 +4357,7 @@ send_wrapped(From, To, Packet, Node, State) ->
|
|||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end
|
end
|
||||||
catch _:_ ->
|
catch _:{badkey, _} ->
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
true ->
|
true ->
|
||||||
|
Loading…
Reference in New Issue
Block a user