Consider this function.
Options[foo]={WorkingPrecision->MachinePrecision};
SyntaxInformation[foo]={"ArgumentsPattern"->{_,OptionsPattern[]}};
foo[expr_,OptionsPattern[foo]]:=
With[{prec=OptionValue@WorkingPrecision},
If[TrueQ[0<prec<=Infinity],N[expr,prec],(* else *)Indeterminate]
];
In this case it does what I want.

But when given invalid options, foo should display a message and return what it was given. This is an example.

The Message above can be displayed using this:
Message[foo::optx,PlotRange,
Inactive@foo[Sqrt[2],WorkingPrecision->20,PlotRange->All]
]
So how do I get my code to find the invalid option and return the expression it was given?

CheckArguments[]? Its docs give a model for this sort of behavior under "Applications". – Michael E2 Sep 07 '23 at 15:24