rabbit_prelaunch_errors: Handle exception stacktraces with args list

... instead of function arity.

I don't know when this was introduced, perhaps Erlang 23. Anyway, each
stacktrace entry has now the form:

    {Mod, Fun, ArgListOrArity, Props}

where `ArgListOrArity` is either the function arity (an integer) or the
actual list of arguments passed to the function.

If we get the latter, we format the stacktrace line as usual and we add
the list of arguments to the line below it.
This commit is contained in:
Jean-Sébastien Pédron 2021-03-23 16:56:31 +01:00
parent 008e47ef3c
commit f3f5606f22
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
1 changed files with 24 additions and 11 deletions

View File

@ -98,15 +98,31 @@ log_exception(Class, Exception, Stacktrace) ->
log_message(Message).
format_exception(Class, Exception, Stacktrace) ->
StacktraceStrs = [case proplists:get_value(line, Props) of
undefined ->
io_lib:format(" ~ts:~ts/~b",
[Mod, Fun, format_arity(Arity)]);
Line ->
io_lib:format(" ~ts:~ts/~b, line ~b",
[Mod, Fun, format_arity(Arity), Line])
StacktraceStrs = [begin
case proplists:get_value(line, Props) of
undefined when is_list(ArgListOrArity) ->
io_lib:format(
" ~ts:~ts/~b~n"
" args: ~p",
[Mod, Fun, length(ArgListOrArity),
ArgListOrArity]);
undefined when is_integer(ArgListOrArity) ->
io_lib:format(
" ~ts:~ts/~b",
[Mod, Fun, ArgListOrArity]);
Line when is_list(ArgListOrArity) ->
io_lib:format(
" ~ts:~ts/~b, line ~b~n"
" args: ~p",
[Mod, Fun, length(ArgListOrArity), Line,
ArgListOrArity]);
Line when is_integer(ArgListOrArity) ->
io_lib:format(
" ~ts:~ts/~b, line ~b",
[Mod, Fun, ArgListOrArity, Line])
end
end
|| {Mod, Fun, Arity, Props} <- Stacktrace],
|| {Mod, Fun, ArgListOrArity, Props} <- Stacktrace],
ExceptionStr = io_lib:format("~ts:~0p", [Class, Exception]),
rabbit_misc:format(
"Exception during startup:~n~n~s~n~n~s",
@ -128,6 +144,3 @@ log_message(Message) ->
end, Lines),
timer:sleep(1000),
ok.
format_arity(N) when is_integer(N) -> N;
format_arity(Args) when is_list(Args) -> length(Args).