1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 01:39:35 +02:00

Remove EX_RULE and EX_STACK macros

As we no longer targer R19, we no longer need to carry those.
This commit is contained in:
Pawel Chmielowski 2025-09-22 17:49:33 +02:00
parent 4dea2f1eb6
commit 19b7106124
27 changed files with 252 additions and 264 deletions

View file

@ -1,27 +0,0 @@
%%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2025 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%----------------------------------------------------------------------
-ifdef(DEPRECATED_GET_STACKTRACE).
-define(EX_RULE(Class, Reason, Stack), Class:Reason:Stack).
-define(EX_STACK(Stack), Stack).
-else.
-define(EX_RULE(Class, Reason, _), Class:Reason).
-define(EX_STACK(_), erlang:get_stacktrace()).
-endif.

View file

@ -85,7 +85,6 @@ defmodule Ejabberd.MixProject do
result = [{:d, :ELIXIR_ENABLED}] ++
cond_options() ++
Enum.map(includes, fn (path) -> {:i, path} end) ++
if_version_above(~c"20", [{:d, :DEPRECATED_GET_STACKTRACE}]) ++
if_version_above(~c"20", [{:d, :HAVE_URI_STRING}]) ++
if_version_above(~c"20", [{:d, :HAVE_ERL_ERROR}]) ++
if_version_below(~c"21", [{:d, :USE_OLD_HTTP_URI}]) ++

View file

@ -126,7 +126,6 @@
{erl_opts, [nowarn_deprecated_function,
{i, "include"},
{if_version_above, "20", {d, 'DEPRECATED_GET_STACKTRACE'}},
{if_version_above, "20", {d, 'HAVE_ERL_ERROR'}},
{if_version_above, "20", {d, 'HAVE_URI_STRING'}},
{if_version_below, "21", {d, 'USE_OLD_HTTP_URI'}},

View file

@ -32,7 +32,7 @@
-export([start/2, prep_stop/1, stop/1]).
-include("logger.hrl").
-include("ejabberd_stacktrace.hrl").
%%%
%%% Application API

View file

@ -52,7 +52,7 @@
{get_lang, 1}]).
-include("logger.hrl").
-include("ejabberd_stacktrace.hrl").
-type option() :: atom() | {atom(), global | binary()}.
-type error_reason() :: {merge_conflict, atom(), binary()} |
@ -169,8 +169,8 @@ get_option({O, Host} = Opt) ->
T -> T
end,
try ets:lookup_element(Tab, Opt, 2)
catch ?EX_RULE(error, badarg, St) when Host /= global ->
StackTrace = ?EX_STACK(St),
catch
error:badarg:StackTrace when Host /= global ->
Val = get_option({O, global}),
?DEBUG("Option '~ts' is not defined for virtual host '~ts'. "
"This is a bug, please report it with the following "
@ -802,8 +802,9 @@ load_file(File) ->
Err ->
abort(Err)
end
catch ?EX_RULE(Class, Reason, St) ->
{error, {exception, Class, Reason, ?EX_STACK(St)}}
catch
Class:Reason:Stack ->
{error, {exception, Class, Reason, Stack}}
end.
-spec commit() -> ok.

View file

@ -39,7 +39,7 @@
-include("ejabberd_commands.hrl").
-include("ejabberd_http.hrl").
-include("logger.hrl").
-include("ejabberd_stacktrace.hrl").
-define(DEFAULT_VERSION, 1000000).
@ -331,8 +331,7 @@ try_call_command(Args, Auth, AccessCommands, Version) ->
?STATUS_ERROR};
throw:Error ->
{io_lib:format("~p", [Error]), ?STATUS_ERROR};
?EX_RULE(A, Why, Stack) ->
StackTrace = ?EX_STACK(Stack),
A:Why:StackTrace ->
{io_lib:format("Unhandled exception occurred executing the command:~n** ~ts",
[misc:format_exception(2, A, Why, StackTrace)]),
?STATUS_ERROR}

View file

@ -60,7 +60,7 @@
).
-include("logger.hrl").
-include("ejabberd_stacktrace.hrl").
-record(state, {}).
-type subscriber() :: {Module :: atom(), Function :: atom(), InitArg :: any()}.
@ -455,16 +455,18 @@ safe_apply(Hook, Module, Function, Args) ->
true ->
apply(Module, Function, Args)
end
catch ?EX_RULE(E, R, St) when E /= exit; R /= normal ->
Stack = ?EX_STACK(St),
catch
E:R:Stack when E /= exit; R /= normal ->
?ERROR_MSG("Hook ~p crashed when running ~p:~p/~p:~n" ++
string:join(
["** ~ts"|
["** Arg " ++ integer_to_list(I) ++ " = ~p"
|| I <- lists:seq(1, length(Args))]],
["** ~ts" | [ "** Arg " ++ integer_to_list(I) ++ " = ~p"
|| I <- lists:seq(1, length(Args)) ]],
"~n"),
[Hook, Module, Function, length(Args),
misc:format_exception(2, E, R, Stack)|Args]),
[Hook,
Module,
Function,
length(Args),
misc:format_exception(2, E, R, Stack) | Args]),
'EXIT'
end.
@ -480,16 +482,18 @@ call_subscriber_list([{Mod, Func, InitArg} | SubscriberList], Host, Hook, Callba
try apply(Mod, Func, SubscriberArgs) of
State ->
call_subscriber_list(SubscriberList, Host, Hook, CallbackOrArgs, Event, [{Mod, Func, State} | Result])
catch ?EX_RULE(E, R, St) when E /= exit; R /= normal ->
Stack = ?EX_STACK(St),
catch
E:R:Stack when E /= exit; R /= normal ->
?ERROR_MSG("Hook subscriber ~p crashed when running ~p:~p/~p:~n" ++
string:join(
["** ~ts"|
["** Arg " ++ integer_to_list(I) ++ " = ~p"
|| I <- lists:seq(1, length(SubscriberArgs))]],
["** ~ts" | [ "** Arg " ++ integer_to_list(I) ++ " = ~p"
|| I <- lists:seq(1, length(SubscriberArgs)) ]],
"~n"),
[Hook, Mod, Func, length(SubscriberArgs),
misc:format_exception(2, E, R, Stack)|SubscriberArgs]),
[Hook,
Mod,
Func,
length(SubscriberArgs),
misc:format_exception(2, E, R, Stack) | SubscriberArgs]),
%% Do not append subscriber for next calls:
call_subscriber_list(SubscriberList, Host, Hook, CallbackOrArgs, Event, Result)
end.
@ -709,12 +713,10 @@ run_event_handlers(TracingOpts, Hook, Host, Event, EventArgs, RunType) ->
_ ->
ok
catch
?EX_RULE(E, R, St) ->
Stack = ?EX_STACK(St),
E:R:Stack ->
?ERROR_MSG(
"(~0p|~ts|~0p) Tracing event '~0p' handler exception(~0p): ~0p: ~0p",
[Hook, Host, erlang:self(), EventHandler, E, R, Stack]
),
[Hook, Host, erlang:self(), EventHandler, E, R, Stack]),
ok
end
end,
@ -885,8 +887,7 @@ tracing_output(#{output_function := OutputF}, Text, Args) ->
_ ->
ok
catch
?EX_RULE(E, R, St) ->
Stack = ?EX_STACK(St),
E:R:Stack ->
?ERROR_MSG("Tracing output function exception(~0p): ~0p: ~0p", [E, R, Stack]),
ok
end;

View file

@ -39,7 +39,7 @@
-include("logger.hrl").
-include_lib("xmpp/include/xmpp.hrl").
-include("ejabberd_http.hrl").
-include("ejabberd_stacktrace.hrl").
-include_lib("kernel/include/file.hrl").
-record(state, {sockmod,
@ -372,11 +372,11 @@ process(Handlers, Request) ->
try
HandlerModule:process(LocalPath, Request)
catch
?EX_RULE(Class, Reason, Stack) ->
Class:Reason:Stack ->
?ERROR_MSG(
"HTTP handler crashed: ~s",
[misc:format_exception(2, Class, Reason, ?EX_STACK(Stack))]),
erlang:raise(Class, Reason, ?EX_STACK(Stack))
[misc:format_exception(2, Class, Reason, Stack)]),
erlang:raise(Class, Reason, Stack)
end
end,
ejabberd_hooks:run(http_request_debug, [{LocalPath, Request}]),

View file

@ -36,7 +36,7 @@
-include_lib("xmpp/include/xmpp.hrl").
-include("logger.hrl").
-include("ejabberd_stacktrace.hrl").
-record(state, {expire = infinity :: timeout()}).
-type state() :: #state{}.
@ -174,8 +174,8 @@ calc_checksum(Data) ->
-spec callback(atom() | pid(), #iq{} | timeout, term()) -> any().
callback(undefined, IQRes, Fun) ->
try Fun(IQRes)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to process iq response:~n~ts~n** ~ts",
[xmpp:pp(IQRes),
misc:format_exception(2, Class, Reason, StackTrace)])

View file

@ -48,7 +48,7 @@
-include("logger.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include_lib("xmpp/include/xmpp.hrl").
-include("ejabberd_stacktrace.hrl").
-include("translate.hrl").
-record(state, {}).

View file

@ -42,7 +42,7 @@
-define(NEED_RESET, [local_content, type]).
-include("logger.hrl").
-include("ejabberd_stacktrace.hrl").
-record(state, {tables = #{} :: tables(),
schema = [] :: [{atom(), custom_schema()}]}).
@ -377,12 +377,13 @@ do_transform(OldAttrs, Attrs, Old) ->
transform_fun(Module, Name) ->
fun(Obj) ->
try Module:transform(Obj)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to transform Mnesia table ~ts:~n"
"** Record: ~p~n"
"** ~ts",
[Name, Obj,
[Name,
Obj,
misc:format_exception(2, Class, Reason, StackTrace)]),
erlang:raise(Class, Reason, StackTrace)
end

View file

@ -48,7 +48,7 @@
-define(CALL_TIMEOUT, 60*1000). %% 60 seconds
-include("logger.hrl").
-include("ejabberd_stacktrace.hrl").
-record(state, {connection :: pid() | undefined,
num :: pos_integer(),
@ -114,9 +114,10 @@ multi(F) ->
{error, _} = Err -> Err;
Result -> get_result(Result)
end
catch ?EX_RULE(E, R, St) ->
catch
E:R:St ->
erlang:erase(?TR_STACK),
erlang:raise(E, R, ?EX_STACK(St))
erlang:raise(E, R, St)
end;
_ ->
erlang:error(nested_transaction)

View file

@ -70,7 +70,8 @@
-include("logger.hrl").
-include("ejabberd_router.hrl").
-include_lib("xmpp/include/xmpp.hrl").
-include("ejabberd_stacktrace.hrl").
-callback init() -> any().
-callback register_route(binary(), binary(), local_hint(),
@ -90,8 +91,8 @@ start_link() ->
-spec route(stanza()) -> ok.
route(Packet) ->
try do_route(Packet)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to route packet:~n~ts~n** ~ts",
[xmpp:pp(Packet),
misc:format_exception(2, Class, Reason, StackTrace)])

View file

@ -32,7 +32,8 @@
-include("logger.hrl").
-include("ejabberd_sql_pt.hrl").
-include("ejabberd_router.hrl").
-include("ejabberd_stacktrace.hrl").
%%%===================================================================
%%% API
@ -141,13 +142,13 @@ row_to_route(Domain, {ServerHost, NodeS, PidS, LocalHintS} = Row) ->
local_hint = dec_local_hint(LocalHintS)}]
catch _:{bad_node, _} ->
[];
?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to decode row from 'route' table:~n"
"** Row = ~p~n"
"** Domain = ~ts~n"
"** ~ts",
[Row, Domain,
[Row,
Domain,
misc:format_exception(2, Class, Reason, StackTrace)]),
[]
end.

View file

@ -53,7 +53,7 @@
-include_lib("xmpp/include/xmpp.hrl").
-include("ejabberd_commands.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include("ejabberd_stacktrace.hrl").
-include("translate.hrl").
-define(DEFAULT_MAX_S2S_CONNECTIONS_NUMBER, 1).
@ -249,8 +249,8 @@ handle_info({mnesia_system_event, {mnesia_up, Node}}, State) ->
{noreply, State};
handle_info({route, Packet}, State) ->
try route(Packet)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to route packet:~n~ts~n** ~ts",
[xmpp:pp(Packet),
misc:format_exception(2, Class, Reason, StackTrace)])

View file

@ -92,7 +92,7 @@
-include_lib("xmpp/include/xmpp.hrl").
-include("ejabberd_commands.hrl").
-include("ejabberd_sm.hrl").
-include("ejabberd_stacktrace.hrl").
-include("translate.hrl").
-callback init() -> ok | {error, any()}.
@ -131,12 +131,13 @@ stop() ->
%% @doc route arbitrary term to c2s process(es)
route(To, Term) ->
try do_route(To, Term), ok
catch ?EX_RULE(E, R, St) ->
StackTrace = ?EX_STACK(St),
catch
E:R:StackTrace ->
?ERROR_MSG("Failed to route term to ~ts:~n"
"** Term = ~p~n"
"** ~ts",
[jid:encode(To), Term,
[jid:encode(To),
Term,
misc:format_exception(2, E, R, StackTrace)])
end.

View file

@ -89,7 +89,7 @@
-include("logger.hrl").
-include("ejabberd_sql_pt.hrl").
-include("ejabberd_stacktrace.hrl").
-record(state,
{db_ref :: undefined | db_ref_pid() | odbc_connection_reference(),
@ -616,18 +616,19 @@ outer_transaction(F, NRestarts, _Reason) ->
{atomic, Res}
end
catch
?EX_RULE(throw, {aborted, Reason}, _) when NRestarts > 0 ->
throw:{aborted, Reason}:_ when NRestarts > 0 ->
maybe_restart_transaction(F, NRestarts, Reason, true);
?EX_RULE(throw, {aborted, Reason}, Stack) when NRestarts =:= 0 ->
StackTrace = ?EX_STACK(Stack),
throw:{aborted, Reason}:StackTrace when NRestarts =:= 0 ->
?ERROR_MSG("SQL transaction restarts exceeded~n** "
"Restarts: ~p~n** Last abort reason: "
"~p~n** Stacktrace: ~p~n** When State "
"== ~p",
[?MAX_TRANSACTION_RESTARTS, Reason,
StackTrace, get(?STATE_KEY)]),
[?MAX_TRANSACTION_RESTARTS,
Reason,
StackTrace,
get(?STATE_KEY)]),
maybe_restart_transaction(F, NRestarts, Reason, true);
?EX_RULE(_, Reason, _) ->
_:Reason:_ ->
maybe_restart_transaction(F, 0, Reason, true)
end
end.
@ -742,8 +743,7 @@ sql_query_internal(#sql_query{} = Query) ->
{error, <<"terminated unexpectedly">>};
exit:{shutdown, _} ->
{error, <<"shutdown">>};
?EX_RULE(Class, Reason, Stack) ->
StackTrace = ?EX_STACK(Stack),
Class:Reason:StackTrace ->
?ERROR_MSG("Internal error while processing SQL query:~n** ~ts",
[misc:format_exception(2, Class, Reason, StackTrace)]),
{error, <<"internal error">>}
@ -935,8 +935,7 @@ sql_query_format_res({selected, _, Rows}, SQLQuery) ->
try
[(SQLQuery#sql_query.format_res)(Row)]
catch
?EX_RULE(Class, Reason, Stack) ->
StackTrace = ?EX_STACK(Stack),
Class:Reason:StackTrace ->
?ERROR_MSG("Error while processing SQL query result:~n"
"** Row: ~p~n** ~ts",
[Row,

View file

@ -37,7 +37,7 @@
-include("logger.hrl").
-include_lib("xmpp/include/xmpp.hrl").
-include("translate.hrl").
-include("ejabberd_stacktrace.hrl").
-type component() :: ejabberd_sm | ejabberd_local.
@ -111,8 +111,8 @@ process_iq(_Host, Module, Function, IQ) ->
ejabberd_router:route(ResIQ);
ignore ->
ok
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to process iq:~n~ts~n** ~ts",
[xmpp:pp(IQ),
misc:format_exception(2, Class, Reason, StackTrace)]),

View file

@ -44,7 +44,7 @@
-include("logger.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include("ejabberd_stacktrace.hrl").
-include("ejabberd_commands.hrl").
-record(ejabberd_module,
@ -187,12 +187,16 @@ start_module(Host, Module, Opts, Order) ->
ets:delete(ejabberd_modules, {Module, Host}),
erlang:error({bad_return, Module, Err})
end
catch ?EX_RULE(Class, Reason, Stack) ->
StackTrace = ?EX_STACK(Stack),
catch
Class:Reason:StackTrace ->
ets:delete(ejabberd_modules, {Module, Host}),
ErrorText = format_module_error(
Module, start, 2,
Opts, Class, Reason,
Module,
start,
2,
Opts,
Class,
Reason,
StackTrace),
?CRITICAL_MSG(ErrorText, []),
maybe_halt_ejabberd(),
@ -246,11 +250,15 @@ reload_module(Host, Module, NewOpts, OldOpts, Order) ->
{ok, Pid} when is_pid(Pid) -> {ok, Pid};
Err -> erlang:error({bad_return, Module, Err})
end
catch ?EX_RULE(Class, Reason, Stack) ->
StackTrace = ?EX_STACK(Stack),
catch
Class:Reason:StackTrace ->
ErrorText = format_module_error(
Module, reload, 3,
NewOpts, Class, Reason,
Module,
reload,
3,
NewOpts,
Class,
Reason,
StackTrace),
?CRITICAL_MSG(ErrorText, []),
erlang:raise(Class, Reason, StackTrace)
@ -346,12 +354,13 @@ prep_stop_module_keep_config(Host, Module) ->
try Module:prep_stop(Host) of
_ ->
ok
catch ?EX_RULE(error, undef, _St) ->
catch
error:undef:_St ->
ok;
?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to prepare stop module ~ts at ~ts:~n** ~ts",
[Module, Host,
[Module,
Host,
misc:format_exception(2, Class, Reason, StackTrace)]),
error
end.
@ -371,10 +380,11 @@ stop_module_keep_config(Host, Module) ->
_ ->
ets:delete(ejabberd_modules, {Module, Host}),
ok
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to stop module ~ts at ~ts:~n** ~ts",
[Module, Host,
[Module,
Host,
misc:format_exception(2, Class, Reason, StackTrace)]),
error
end.

View file

@ -36,7 +36,7 @@
-include_lib("xmpp/include/xmpp.hrl").
-include("logger.hrl").
-include("ejabberd_http.hrl").
-include("ejabberd_stacktrace.hrl").
-include("translate.hrl").
-define(DEFAULT_API_VERSION, 1000000).
@ -148,8 +148,7 @@ process([Call | _], #request{method = 'POST', data = Data, ip = IPPort} = Req) -
_:{error,{_,invalid_json}} = Err ->
?DEBUG("Bad Request: ~p", [Err]),
badrequest_response(<<"Invalid JSON input">>);
?EX_RULE(_Class, Error, Stack) ->
StackTrace = ?EX_STACK(Stack),
_Class:Error:StackTrace ->
?DEBUG("Bad Request: ~p ~p", [Error, StackTrace]),
badrequest_response()
end;
@ -166,8 +165,7 @@ process([Call | _], #request{method = 'GET', q = Data, ip = {IP, _}} = Req) ->
%% TODO We need to refactor to remove redundant error return formatting
throw:{error, unknown_command} ->
json_format({404, 44, <<"Command not found.">>});
?EX_RULE(_, Error, Stack) ->
StackTrace = ?EX_STACK(Stack),
_:Error:StackTrace ->
?DEBUG("Bad Request: ~p ~p", [Error, StackTrace]),
badrequest_response()
end;
@ -257,12 +255,14 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
{400, misc:atom_to_binary(Error)};
throw:Msg when is_list(Msg); is_binary(Msg) ->
{400, iolist_to_binary(Msg)};
?EX_RULE(Class, Error, Stack) ->
StackTrace = ?EX_STACK(Stack),
Class:Error:StackTrace ->
?ERROR_MSG("REST API Error: "
"~ts(~p) -> ~p:~p ~p",
[Call, hide_sensitive_args(Args),
Class, Error, StackTrace]),
[Call,
hide_sensitive_args(Args),
Class,
Error,
StackTrace]),
{500, <<"internal_error">>}
end.

View file

@ -44,7 +44,8 @@
-include_lib("xmpp/include/xmpp.hrl").
-include("logger.hrl").
-include("translate.hrl").
-include("ejabberd_stacktrace.hrl").
-callback init(binary(), gen_mod:opts()) -> ok | {error, db_failure}.
-callback set_channel(binary(), binary(), binary(),
@ -319,8 +320,8 @@ handle_cast(Request, State) ->
handle_info({route, Packet}, State) ->
try route(Packet)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to route packet:~n~ts~n** ~ts",
[xmpp:pp(Packet),
misc:format_exception(2, Class, Reason, StackTrace)])

View file

@ -85,7 +85,7 @@
-include("mod_muc.hrl").
-include("mod_muc_room.hrl").
-include("translate.hrl").
-include("ejabberd_stacktrace.hrl").
-type state() :: #{hosts := [binary()],
server_host := binary(),
@ -454,8 +454,8 @@ handle_call({create, Room, Host, From, Nick, Opts}, _From,
-spec handle_cast(term(), state()) -> {noreply, state()}.
handle_cast({route_to_room, Packet}, #{server_host := ServerHost} = State) ->
try route_to_room(Packet, ServerHost)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to route packet:~n~ts~n** ~ts",
[xmpp:pp(Packet),
misc:format_exception(2, Class, Reason, StackTrace)])
@ -483,8 +483,8 @@ handle_info({route, Packet}, #{server_host := ServerHost} = State) ->
%% where mod_muc is not loaded. Such configuration
%% is *highly* discouraged
try route(Packet, ServerHost)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to route packet:~n~ts~n** ~ts",
[xmpp:pp(Packet),
misc:format_exception(2, Class, Reason, StackTrace)])

View file

@ -74,7 +74,7 @@
-include_lib("xmpp/include/xmpp.hrl").
-include("translate.hrl").
-include("mod_muc_room.hrl").
-include("ejabberd_stacktrace.hrl").
-define(MAX_USERS_DEFAULT_LIST,
[5, 10, 20, 30, 50, 100, 200, 500, 1000, 2000, 5000]).
@ -1027,8 +1027,8 @@ terminate(Reason, _StateName,
ok
end
end
catch ?EX_RULE(E, R, St) ->
StackTrace = ?EX_STACK(St),
catch
E:R:StackTrace ->
?ERROR_MSG("Got exception on room termination:~n** ~ts",
[misc:format_exception(2, E, R, StackTrace)])
end.
@ -3266,8 +3266,8 @@ process_item_change(Item, SD, UJID) ->
maybe_send_affiliation(JID, A, SD1),
SD1
end
catch ?EX_RULE(E, R, St) ->
StackTrace = ?EX_STACK(St),
catch
E:R:StackTrace ->
FromSuffix = case UJID of
#jid{} ->
JidString = jid:encode(UJID),
@ -3276,7 +3276,8 @@ process_item_change(Item, SD, UJID) ->
<<"">>
end,
?ERROR_MSG("Failed to set item ~p~ts:~n** ~ts",
[Item, FromSuffix,
[Item,
FromSuffix,
misc:format_exception(2, E, R, StackTrace)]),
{error, xmpp:err_internal_server_error()}
end.

View file

@ -40,7 +40,7 @@
-include("logger.hrl").
-include_lib("xmpp/include/xmpp.hrl").
-include("translate.hrl").
-include("ejabberd_stacktrace.hrl").
-define(PROCNAME, ejabberd_mod_proxy65_service).
@ -86,8 +86,8 @@ terminate(_Reason, #state{myhosts = MyHosts}) ->
handle_info({route, Packet}, State) ->
try route(Packet)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to route packet:~n~ts~n** ~ts",
[xmpp:pp(Packet),
misc:format_exception(2, Class, Reason, StackTrace)])

View file

@ -46,7 +46,7 @@
-include("pubsub.hrl").
-include("mod_roster.hrl").
-include("translate.hrl").
-include("ejabberd_stacktrace.hrl").
-include("ejabberd_commands.hrl").
-define(STDTREE, <<"tree">>).
@ -748,8 +748,8 @@ handle_cast(Msg, State) ->
handle_info({route, Packet}, State) ->
try route(Packet)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to route packet:~n~ts~n** ~ts",
[xmpp:pp(Packet),
misc:format_exception(2, Class, Reason, StackTrace)])
@ -3819,8 +3819,8 @@ tree_action(Host, Function, Args) ->
DBType = mod_pubsub_opt:db_type(ServerHost),
Fun = fun () ->
try tree_call(Host, Function, Args)
catch ?EX_RULE(Class, Reason, St) when DBType == sql ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace when DBType == sql ->
ejabberd_sql:abort({exception, Class, Reason, StackTrace})
end
end,
@ -3919,10 +3919,10 @@ transaction(Host, Fun, Trans) ->
do_transaction(ServerHost, Fun, Trans, DBType) ->
F = fun() ->
try Fun()
catch ?EX_RULE(Class, Reason, St) when (DBType == mnesia andalso
catch
Class:Reason:StackTrace when (DBType == mnesia andalso
Trans == transaction) orelse
DBType == sql ->
StackTrace = ?EX_STACK(St),
Ex = {exception, Class, Reason, StackTrace},
case DBType of
mnesia -> mnesia:abort(Ex);

View file

@ -61,7 +61,7 @@
-include("mod_roster.hrl").
-include("ejabberd_http.hrl").
-include("ejabberd_web_admin.hrl").
-include("ejabberd_stacktrace.hrl").
-include("translate.hrl").
-define(ROSTER_CACHE, roster_cache).

View file

@ -51,7 +51,7 @@
-include_lib("xmpp/include/xmpp.hrl").
-include("mod_vcard.hrl").
-include("translate.hrl").
-include("ejabberd_stacktrace.hrl").
-include("ejabberd_http.hrl").
-include("ejabberd_web_admin.hrl").
@ -151,8 +151,8 @@ handle_cast(Cast, State) ->
handle_info({route, Packet}, State) ->
try route(Packet)
catch ?EX_RULE(Class, Reason, St) ->
StackTrace = ?EX_STACK(St),
catch
Class:Reason:StackTrace ->
?ERROR_MSG("Failed to route packet:~n~ts~n** ~ts",
[xmpp:pp(Packet),
misc:format_exception(2, Class, Reason, StackTrace)])