Browse Source

Merge pull request #48 from basho/adt-badrecord-support

Add support for badrecord errors
pull/51/head
Andrew Thompson 13 years ago
parent
commit
698c9918cf
3 changed files 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

+ 2
- 0
src/error_logger_lager_h.erl View File

@ -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|_]}) ->

+ 8
- 0
test/crash.erl View File

@ -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) ->

+ 9
- 0
test/lager_test_backend.erl View File

@ -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),

Loading…
Cancel
Save