As acl points out, this postthis post shows you how to setup error highlighting for invalid number of arguments. Coming to the actual error messages used, there are three built-in messages attached to General
, that can be used for your own functions as well. These are argx
, argrx
and argt
:
General::argx
(* "`1` called with `2` arguments; 1 argument is expected." *)
General::argrx
(* "`1` called with `2` arguments; `3` arguments are expected." *)
General::argt
(* "`1` called with `2` arguments; `3` or `4` arguments are expected." *)
You can attach these messages to your own functions (any message defined for General
can be used for any other symbol) like in the following example (shown only for argx
):
ClearAll@f
SyntaxInformation[f] = {"ArgumentsPattern" -> {_}};
f[1] := True
f[_] := False
f[_, x__] := Message[f::argx, "f", Length@{x} + 1]