Description
In rust-analyzer, if you try to rename a thing using invalid name, you get the following result:
The first message makes sense -- the user typed a bad name.
The second message doesn't make sense -- there's no reason to look at the server's log, that's just confusing and wrong.
What happens here is that the requested name, '92
isn't a valid identifier, so we need to return some error. The protocol currently specifies that we need to return an JSON RPC level error, for which we need to pick an error type. We pick InvalidParams
, as there doesn't seem to be a better choice.
But I think InvalidParams
usually means something different -- that the server and the client disagree about protocol (ie, use different type definitions/serialization formats). So the client, correctly, asks the user to look into the error log for the server.
That is, I think the issue here is that we can't (or at least I don't know how to do it) distinguish between user errors and protocol implementation errors. A plausible solution here is to introduce a dedicated error code for "user provided invalid input".
I got curious what's TypeScript take here. Turns out, you can just rename something to 111!!! lol
:-)