Skip to content

Commit 7c98955

Browse files
committed
Make error message in clearer when registering methods that have the same name.
1 parent 5bf1ab1 commit 7c98955

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Json-Rpc/SMDService.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ public SMD ()
4343
//}
4444

4545
// alexbclarke: Suggesed fix.
46-
// Check is a method has already been added before adding it.
4746
internal void AddService(string method, Dictionary<string, Type> parameters, Dictionary<string, object> defaultValues, Delegate dele)
4847
{
4948
if (!Services.ContainsKey(method))
5049
{
5150
var newService = new SMDService(transport, "JSON-RPC-2.0", parameters, defaultValues, dele);
5251
Services.Add(method, newService);
5352
}
53+
else
54+
{
55+
throw new ArgumentException($"Failed to register method '{method}' in class '{dele.Target.ToString()}'. " +
56+
"A method with the same name has already been registered.");
57+
}
5458
}
5559

5660
public static int AddType(JObject jo)

0 commit comments

Comments
 (0)