Skip to content
Browse files

Add support for badrecord errors

  • Loading branch information...
1 parent a837eb8 commit 62bb41fd350f5025f3a910c8d2b52ce44556dc71 @Vagabond Vagabond committed
Showing with 19 additions and 0 deletions.
  1. +2 −0 src/error_logger_lager_h.erl
  2. +8 −0 test/crash.erl
  3. +9 −0 test/lager_test_backend.erl
View
2 src/error_logger_lager_h.erl
@@ -202,6 +202,8 @@ format_reason({bad_return_value, Val}) ->
["bad return value: ", print_val(Val)];
format_reason({{bad_return_value, Val}, MFA}) ->
["bad return value: ", print_val(Val), " in ", format_mfa(MFA)];
+format_reason({{badrecord, Record}, [MFA|_]}) ->
+ ["bad record ", print_val(Record), " in ", format_mfa(MFA)];
format_reason({{case_clause, Val}, [MFA|_]}) ->
["no case clause matching ", print_val(Val), " in ", format_mfa(MFA)];
format_reason({function_clause, [MFA|_]}) ->
View
8 test/crash.erl
@@ -9,6 +9,11 @@
-export([start/0]).
+-record(state, {
+ host,
+ port
+ }).
+
start() ->
gen_server:start({local, ?MODULE}, ?MODULE, [], []).
@@ -49,6 +54,9 @@ handle_call(try_clause, _, State) ->
handle_call(badmatch, _, State) ->
{A, B, C} = State,
{reply, [A, B, C], State};
+handle_call(badrecord, _, State) ->
+ Host = State#state.host,
+ {reply, Host, State};
handle_call(function_clause, _, State) ->
{reply, function(State), State};
handle_call(badarith, _, State) ->
View
9 test/lager_test_backend.erl
@@ -404,6 +404,15 @@ error_logger_redirect_crash_test_() ->
test_body(Expected, lists:flatten(Msg))
end
},
+ {"bad record",
+ fun() ->
+ Pid = whereis(crash),
+ crash(badrecord),
+ {_, _, Msg} = pop(),
+ Expected = lists:flatten(io_lib:format("[error] ~w gen_server crash terminated with reason: bad record state in crash:handle_call/3", [Pid])),
+ test_body(Expected, lists:flatten(Msg))
+ end
+ },
{"noproc",
fun() ->
Pid = whereis(crash),

0 comments on commit 62bb41f

Please sign in to comment.
Something went wrong with that request. Please try again.