Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

Add support for badrecord errors
  • Loading branch information...
commit 698c9918cf4148fb32a23b0604917a11fc7dc24f 2 parents a837eb8 + 62bb41f
Andrew Thompson authored April 18, 2012
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),

0 notes on commit 698c991

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