Skip to content
This repository

Add support for badrecord errors #48

Merged
merged 1 commit into from about 2 years ago

2 participants

Andrew Thompson Russell Brown
Andrew Thompson

No description provided.

Russell Brown
Collaborator

Looks good, tests pass +1.

Andrew Thompson Vagabond merged commit 698c991 into from
Andrew Thompson Vagabond closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 09, 2012
Andrew Thompson Vagabond Add support for badrecord errors 62bb41f
This page is out of date. Refresh to see the latest.
2  src/error_logger_lager_h.erl
@@ -202,6 +202,8 @@ format_reason({bad_return_value, Val}) ->
202 202 ["bad return value: ", print_val(Val)];
203 203 format_reason({{bad_return_value, Val}, MFA}) ->
204 204 ["bad return value: ", print_val(Val), " in ", format_mfa(MFA)];
  205 +format_reason({{badrecord, Record}, [MFA|_]}) ->
  206 + ["bad record ", print_val(Record), " in ", format_mfa(MFA)];
205 207 format_reason({{case_clause, Val}, [MFA|_]}) ->
206 208 ["no case clause matching ", print_val(Val), " in ", format_mfa(MFA)];
207 209 format_reason({function_clause, [MFA|_]}) ->
8 test/crash.erl
@@ -9,6 +9,11 @@
9 9
10 10 -export([start/0]).
11 11
  12 +-record(state, {
  13 + host,
  14 + port
  15 + }).
  16 +
12 17 start() ->
13 18 gen_server:start({local, ?MODULE}, ?MODULE, [], []).
14 19
@@ -49,6 +54,9 @@ handle_call(try_clause, _, State) ->
49 54 handle_call(badmatch, _, State) ->
50 55 {A, B, C} = State,
51 56 {reply, [A, B, C], State};
  57 +handle_call(badrecord, _, State) ->
  58 + Host = State#state.host,
  59 + {reply, Host, State};
52 60 handle_call(function_clause, _, State) ->
53 61 {reply, function(State), State};
54 62 handle_call(badarith, _, State) ->
9 test/lager_test_backend.erl
@@ -404,6 +404,15 @@ error_logger_redirect_crash_test_() ->
404 404 test_body(Expected, lists:flatten(Msg))
405 405 end
406 406 },
  407 + {"bad record",
  408 + fun() ->
  409 + Pid = whereis(crash),
  410 + crash(badrecord),
  411 + {_, _, Msg} = pop(),
  412 + Expected = lists:flatten(io_lib:format("[error] ~w gen_server crash terminated with reason: bad record state in crash:handle_call/3", [Pid])),
  413 + test_body(Expected, lists:flatten(Msg))
  414 + end
  415 + },
407 416 {"noproc",
408 417 fun() ->
409 418 Pid = whereis(crash),

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.