[erlang-questions] gen_server init returns {stop, Reason} and fails: possibly doc bug?

Brujo Benavides fernando.benavides@REDACTED
Wed May 3 10:48:39 CEST 2017

You’re correct.
To be able to use the result of gen_server:start_link you must be trapping exits.
I wrote a blog post <https://medium.com/erlang-battleground/the-unstoppable-exception-9dfb009852f5> about it a while back.

> On May 2, 2017, at 11:57, Max Lapshin <max.lapshin@REDACTED> wrote:
> Here:  http://erlang.org/doc/man/gen_server.html#start_link-3 <http://erlang.org/doc/man/gen_server.html#start_link-3>  we can read that start_link will return  {error, Reason} if init callback returns {stop, Reason}
> Maybe I'm wrong, but it seems that it is not possible to get back clean reply, because gen_server.erl  has following code:
> proc_lib:init_ack(Starter, {error, Reason}),  % here we may receive error tuple
> exit(Reason)  
> After exit caller is failing because of linkage. So if we want to have start_link, we cannot get clean logs and clearly get {error, Reason}  tuple.
> Am I wrong?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170503/a2b66d85/attachment.htm>

More information about the erlang-questions mailing list