gen_server documentation

Samuel Rivas samuel@REDACTED
Fri Apr 7 12:02:49 CEST 2006


Hi,

Documentation for gen_server:start_link reads:

  "  If Module:init/1 fails with Reason, the function returns
  {error,Reason}. If Module:init/1 returns {stop,Reason} or ignore, the
  process is terminated and the function returns {error,Reason} or ignore,
  respectively"

For gen_server:start it refers to previous definition.

  However, both functions behaves differently: in both cases start_link exits,
  while start returns {error, Reason}:


%%%%
-module(dumb_server).
-behaviour(gen_server).

-export([init/1]).

init(_) ->
        exit(foo).


1> gen_server:start_link(dumb_server, [], []).
** exited: foo **
2> gen_server:start(dumb_server, [], []).
{error,foo}

%%%%
-module(dumb_server).
-behaviour(gen_server).

-export([init/1]).

init(_) ->
        {stop, foo}.


1> gen_server:start_link(dumb_server, [], []).
** exited: foo **
2> gen_server:start(dumb_server, [], []).     
{error,foo}

-- 
	Samuel



More information about the erlang-questions mailing list