From 0e328bd14f2bc0e05cfc1ce6c44f3692af58ea03 Mon Sep 17 00:00:00 2001 From: Magnus Henoch Date: Fri, 25 Jan 2013 16:54:12 +0000 Subject: Slightly nicer error message when node start fails due to duplicate name When starting up an Erlang node using a node name that is already in use, the new node used to crash with output starting with this message: {error_logger,{{2013,1,25},{16,0,42}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{{badmatch,{error,duplicate_name}},[{inet_tcp_dist,listen,1,[..... With this change, the first line in the output changes to: {error_logger,{{2013,1,25},{16,40,41}},"Protocol: ~tp: the name foo@localhost seems to be in use by another Erlang node",["inet_tcp"]} --- lib/kernel/src/inet6_tcp_dist.erl | 8 ++++++-- lib/kernel/src/inet_tcp_dist.erl | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/kernel/src/inet6_tcp_dist.erl b/lib/kernel/src/inet6_tcp_dist.erl index b9c4fa607c..2315a56582 100644 --- a/lib/kernel/src/inet6_tcp_dist.erl +++ b/lib/kernel/src/inet6_tcp_dist.erl @@ -71,8 +71,12 @@ listen(Name) -> {ok, Socket} -> TcpAddress = get_tcp_address(Socket), {_,Port} = TcpAddress#net_address.address, - {ok, Creation} = erl_epmd:register_node(Name, Port), - {ok, {Socket, TcpAddress, Creation}}; + case erl_epmd:register_node(Name, Port) of + {ok, Creation} -> + {ok, {Socket, TcpAddress, Creation}}; + Error -> + Error + end; Error -> Error end. diff --git a/lib/kernel/src/inet_tcp_dist.erl b/lib/kernel/src/inet_tcp_dist.erl index 7f935c2b36..70f3c87723 100644 --- a/lib/kernel/src/inet_tcp_dist.erl +++ b/lib/kernel/src/inet_tcp_dist.erl @@ -67,8 +67,12 @@ listen(Name) -> {ok, Socket} -> TcpAddress = get_tcp_address(Socket), {_,Port} = TcpAddress#net_address.address, - {ok, Creation} = erl_epmd:register_node(Name, Port), - {ok, {Socket, TcpAddress, Creation}}; + case erl_epmd:register_node(Name, Port) of + {ok, Creation} -> + {ok, {Socket, TcpAddress, Creation}}; + Error -> + Error + end; Error -> Error end. -- cgit v1.2.3