Browse Source

Return invalid_remote_scope with Node info.

Roberto Ostinelli 3 years ago
parent
commit
c905cb19ad
4 changed files with 7 additions and 5 deletions
  1. 2 2
      src/syn.erl
  2. 2 1
      src/syn_gen_scope.erl
  3. 1 1
      test/syn_pg_SUITE.erl
  4. 2 1
      test/syn_registry_SUITE.erl

+ 2 - 2
src/syn.erl

@@ -45,8 +45,8 @@
 %% Please note any of the methods documented here will raise:
 %% <ul>
 %% <li>An `error({invalid_scope, Scope})' if the local node has not been added to the specified Scope.</li>
-%% <li>An `error({invalid_remote_scope, Scope})' if the Pid passed in as variable is running on a node that has not
-%% been added to the specified Scope.</li>
+%% <li>An `error({invalid_remote_scope, Scope, RemoteNode})' if the Pid passed in as variable is running on a
+%% node that has not been added to the specified Scope, or if the remote scope process is temporarily down.</li>
 %% </ul>
 %%
 %% <h2>Quickstart</h2>

+ 2 - 1
src/syn_gen_scope.erl

@@ -106,7 +106,8 @@ call(Handler, Node, Scope, Message) ->
         undefined -> error({invalid_scope, Scope});
         ProcessName ->
             try gen_server:call({ProcessName, Node}, Message)
-            catch exit:{noproc, {gen_server, call, _}} -> error({invalid_remote_scope, Scope})
+            catch exit:{noproc, {gen_server, call, _}} when node() =/= Node ->
+                error({invalid_remote_scope, Scope, Node})
             end
     end.
 

+ 1 - 1
test/syn_pg_SUITE.erl

@@ -360,7 +360,7 @@ three_nodes_join_leave_and_monitor(Config) ->
     %% errors
     {error, not_alive} = syn:join(scope_ab, {"pid not alive"}, list_to_pid("<0.9999.0>")),
     {error, not_in_group} = syn:leave(scope_ab, {group, "three"}, Pid),
-    {'EXIT', {{invalid_remote_scope, scope_ab}, _}} = catch syn:join(scope_ab, {group, "one"}, PidRemoteOn2),
+    {'EXIT', {{invalid_remote_scope, scope_ab, SlaveNode2}, _}} = catch syn:join(scope_ab, {group, "one"}, PidRemoteOn2),
 
     %% retrieve
     syn_test_suite_helper:assert_wait(

+ 2 - 1
test/syn_registry_SUITE.erl

@@ -365,7 +365,8 @@ three_nodes_register_unregister_and_monitor(Config) ->
     {error, not_alive} = syn:register(scope_ab, {"pid not alive"}, list_to_pid("<0.9999.0>")),
     {'EXIT', {{invalid_scope, scope_bc}, _}} = catch syn:register(scope_bc, "scope_a_noscope", Pid),
     {'EXIT', {{invalid_scope, scope_bc}, _}} = catch syn:unregister(scope_bc, "scope_a_noscope"),
-    {badrpc, {'EXIT', {{invalid_remote_scope, scope_bc}, _}}} = catch rpc:call(SlaveNode1, syn, register, [scope_bc, "pid-outside", Pid]),
+    LocalNode = node(),
+    {badrpc, {'EXIT', {{invalid_remote_scope, scope_bc, LocalNode}, _}}} = catch rpc:call(SlaveNode1, syn, register, [scope_bc, "pid-outside", Pid]),
 
     %% retrieve
     syn_test_suite_helper:assert_wait(