25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Use xmpp:io_format_error/1 wherever possible

This commit is contained in:
Evgeniy Khramtsov 2017-11-14 09:02:43 +03:00
parent 474536817e
commit f953621ed2
8 changed files with 10 additions and 10 deletions

View File

@ -164,7 +164,7 @@ process_iq(Module, Function, #iq{lang = Lang, sub_els = [El]} = IQ) ->
end, end,
Module:Function(IQ#iq{sub_els = [Pkt]}) Module:Function(IQ#iq{sub_els = [Pkt]})
catch error:{xmpp_codec, Why} -> catch error:{xmpp_codec, Why} ->
Txt = xmpp:format_error(Why), Txt = xmpp:io_format_error(Why),
xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang)) xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang))
end. end.

View File

@ -418,7 +418,7 @@ handle_info({route_chan, Channel, Resource,
end end
catch _:{xmpp_codec, Why} -> catch _:{xmpp_codec, Why} ->
Err = xmpp:err_bad_request( Err = xmpp:err_bad_request(
xmpp:format_error(Why), xmpp:get_lang(Packet)), xmpp:io_format_error(Why), xmpp:get_lang(Packet)),
ejabberd_router:route_error(Packet, Err) ejabberd_router:route_error(Packet, Err)
end, end,
{next_state, StateName, StateData}; {next_state, StateName, StateData};

View File

@ -491,7 +491,7 @@ process_iq(LServer, #iq{sub_els = [#mam_query{xmlns = NS}]} = IQ) ->
process_iq(#iq{type = set, lang = Lang, process_iq(#iq{type = set, lang = Lang,
sub_els = [#mam_prefs{default = undefined, xmlns = NS}]} = IQ) -> sub_els = [#mam_prefs{default = undefined, xmlns = NS}]} = IQ) ->
Why = {missing_attr, <<"default">>, <<"prefs">>, NS}, Why = {missing_attr, <<"default">>, <<"prefs">>, NS},
ErrTxt = xmpp:format_error(Why), ErrTxt = xmpp:io_format_error(Why),
xmpp:make_error(IQ, xmpp:err_bad_request(ErrTxt, Lang)); xmpp:make_error(IQ, xmpp:err_bad_request(ErrTxt, Lang));
process_iq(#iq{from = #jid{luser = LUser, lserver = LServer}, process_iq(#iq{from = #jid{luser = LUser, lserver = LServer},
to = #jid{lserver = LServer}, to = #jid{lserver = LServer},

View File

@ -251,7 +251,7 @@ normal_state({route, <<"">>,
try xmpp:decode_els(Packet) of try xmpp:decode_els(Packet) of
Pkt -> process_normal_message(From, Pkt, StateData) Pkt -> process_normal_message(From, Pkt, StateData)
catch _:{xmpp_codec, Why} -> catch _:{xmpp_codec, Why} ->
Txt = xmpp:format_error(Why), Txt = xmpp:io_format_error(Why),
Err = xmpp:err_bad_request(Txt, Lang), Err = xmpp:err_bad_request(Txt, Lang),
ejabberd_router:route_error(Packet, Err), ejabberd_router:route_error(Packet, Err),
StateData StateData
@ -329,7 +329,7 @@ normal_state({route, <<"">>,
end end
end end
catch _:{xmpp_codec, Why} -> catch _:{xmpp_codec, Why} ->
ErrTxt = xmpp:format_error(Why), ErrTxt = xmpp:io_format_error(Why),
Err = xmpp:err_bad_request(ErrTxt, Lang), Err = xmpp:err_bad_request(ErrTxt, Lang),
ejabberd_router:route_error(IQ0, Err) ejabberd_router:route_error(IQ0, Err)
end; end;

View File

@ -240,7 +240,7 @@ handle_iq(Packet, State) ->
end end
catch _:{xmpp_codec, Why} -> catch _:{xmpp_codec, Why} ->
Lang = xmpp:get_lang(Packet), Lang = xmpp:get_lang(Packet),
Err = xmpp:err_bad_request(xmpp:format_error(Why), Lang), Err = xmpp:err_bad_request(xmpp:io_format_error(Why), Lang),
ejabberd_router:route_error(Packet, Err) ejabberd_router:route_error(Packet, Err)
end. end.

View File

@ -353,7 +353,7 @@ process_lists_set(#iq{from = #jid{luser = LUser, lserver = LServer} = From,
lang = Lang} = IQ, Name, Items) -> lang = Lang} = IQ, Name, Items) ->
case catch lists:map(fun decode_item/1, Items) of case catch lists:map(fun decode_item/1, Items) of
{error, Why} -> {error, Why} ->
Txt = xmpp:format_error(Why), Txt = xmpp:io_format_error(Why),
xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang)); xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang));
List -> List ->
case set_list(LUser, LServer, Name, List) of case set_list(LUser, LServer, Name, List) of

View File

@ -292,7 +292,7 @@ forward_message(#message{to = To} = Msg) ->
Err = xmpp:err_bad_request(Txt, Lang), Err = xmpp:err_bad_request(Txt, Lang),
ejabberd_router:route_error(Msg, Err) ejabberd_router:route_error(Msg, Err)
catch _:{xmpp_codec, Why} -> catch _:{xmpp_codec, Why} ->
Txt = xmpp:format_error(Why), Txt = xmpp:io_format_error(Why),
Err = xmpp:err_bad_request(Txt, Lang), Err = xmpp:err_bad_request(Txt, Lang),
ejabberd_router:route_error(Msg, Err) ejabberd_router:route_error(Msg, Err)
end; end;

View File

@ -189,12 +189,12 @@ process_bytestreams(#iq{type = set, lang = Lang,
sub_els = [#bytestreams{sid = SID}]} = IQ) sub_els = [#bytestreams{sid = SID}]} = IQ)
when SID == <<"">> orelse size(SID) > 128 -> when SID == <<"">> orelse size(SID) > 128 ->
Why = {bad_attr_value, <<"sid">>, <<"query">>, ?NS_BYTESTREAMS}, Why = {bad_attr_value, <<"sid">>, <<"query">>, ?NS_BYTESTREAMS},
Txt = xmpp:format_error(Why), Txt = xmpp:io_format_error(Why),
xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang)); xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang));
process_bytestreams(#iq{type = set, lang = Lang, process_bytestreams(#iq{type = set, lang = Lang,
sub_els = [#bytestreams{activate = undefined}]} = IQ) -> sub_els = [#bytestreams{activate = undefined}]} = IQ) ->
Why = {missing_cdata, <<"">>, <<"activate">>, ?NS_BYTESTREAMS}, Why = {missing_cdata, <<"">>, <<"activate">>, ?NS_BYTESTREAMS},
Txt = xmpp:format_error(Why), Txt = xmpp:io_format_error(Why),
xmpp:make_error(IQ, xmpp:err_jid_malformed(Txt, Lang)); xmpp:make_error(IQ, xmpp:err_jid_malformed(Txt, Lang));
process_bytestreams(#iq{type = set, lang = Lang, from = InitiatorJID, to = To, process_bytestreams(#iq{type = set, lang = Lang, from = InitiatorJID, to = To,
sub_els = [#bytestreams{activate = TargetJID, sub_els = [#bytestreams{activate = TargetJID,