Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is common to receive an
HTTP 401 Unauthorized
with an empty body when an API token is incorrect. While it's technically true that an empty string is not technically a valid JSON string, the result of this in rest.nvim is quite ungraceful. The user is given a huge messy error stack without any clear indication of what went wrong. And when the error message is closed by hitting enter, the results pane in rest.nvim is stuck in a "# Loading..." state and does not display the HTTP response code, making it very non-obvious what has gone wrong.I reason that when this happens, it would be preferable to simply show the empty response and the 401 HTTP code because this is a preferable experience for the user. I'm very willing to believe there might be a more correct way to solve this problem, but this is what I came up with after a quick bit of wading around the codebase.
Below you can see the current user experience is versus what it looks like after the patch.
Before
After