25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +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,
Module:Function(IQ#iq{sub_els = [Pkt]})
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))
end.

View File

@ -418,7 +418,7 @@ handle_info({route_chan, Channel, Resource,
end
catch _:{xmpp_codec, Why} ->
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)
end,
{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,
sub_els = [#mam_prefs{default = undefined, xmlns = NS}]} = IQ) ->
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));
process_iq(#iq{from = #jid{luser = LUser, lserver = LServer},
to = #jid{lserver = LServer},

View File

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

View File

@ -240,7 +240,7 @@ handle_iq(Packet, State) ->
end
catch _:{xmpp_codec, Why} ->
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)
end.

View File

@ -353,7 +353,7 @@ process_lists_set(#iq{from = #jid{luser = LUser, lserver = LServer} = From,
lang = Lang} = IQ, Name, Items) ->
case catch lists:map(fun decode_item/1, Items) of
{error, Why} ->
Txt = xmpp:format_error(Why),
Txt = xmpp:io_format_error(Why),
xmpp:make_error(IQ, xmpp:err_bad_request(Txt, Lang));
List ->
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),
ejabberd_router:route_error(Msg, Err)
catch _:{xmpp_codec, Why} ->
Txt = xmpp:format_error(Why),
Txt = xmpp:io_format_error(Why),
Err = xmpp:err_bad_request(Txt, Lang),
ejabberd_router:route_error(Msg, Err)
end;

View File

@ -189,12 +189,12 @@ process_bytestreams(#iq{type = set, lang = Lang,
sub_els = [#bytestreams{sid = SID}]} = IQ)
when SID == <<"">> orelse size(SID) > 128 ->
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));
process_bytestreams(#iq{type = set, lang = Lang,
sub_els = [#bytestreams{activate = undefined}]} = IQ) ->
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));
process_bytestreams(#iq{type = set, lang = Lang, from = InitiatorJID, to = To,
sub_els = [#bytestreams{activate = TargetJID,