[erlang-patches] format_status analog for error_info

Andrew Thompson andrew@REDACTED
Wed Feb 24 22:08:53 CET 2010


Okay, I took a stab at implementing it:

git fetch git://github.com/Vagabond/otp.git error_info_modify_state_data

Attached is a very simple gen_server that illustrates the new behaviour.

Comments welcome.

Andrew
-------------- next part --------------
% module to demonstrate proposed change to terminate() behaviour
-module(crash_server).
-behaviour(gen_server).

%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
		terminate/2, code_change/3]).

-export([start/0]).

start() ->
	gen_server:start(?MODULE, [], []).

-record(state, {
		foo = "Foo",
		bar = "bar",
		baz = <<"baz">>
	}).

init([]) ->
	erlang:send_after(500, self(), crash),
	{ok, #state{}}.

handle_call(_Event, _From, State) ->
	{reply, ok, State}.

handle_cast(_Event, State) ->
	{noreply, State}.

handle_info(crash, State) ->
	{stop, crash, State};
handle_info(_Event, State) ->
	{noreply, State}.

code_change(_OldVsn, State, _Extra) ->
	{ok, State}.

terminate(Reason, State) ->
	{error_info, State#state{baz = redacted}}.



More information about the erlang-patches mailing list