Add messages to assertion failures in request_references
and request_document_symbols
#75
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.
When calling the language server, it could return
None
in cases where the input symbol or document is not found. The assertion statements changed here are mostly will be triggered in those cases. However, these cases could be considered expected, rather than errors, so callers should have the choice of catching them and handling them as desired. Without a message accompanying the assertion failure, it's very hard to do so. This PR adds a consistent message to these kinds of failures and they match the existing value insiderequest_definition
in a similar situation.This change is fairly minimal and more or less allows me what I would like to accomplish in my project, which is making sure that I return a nice user error in these "expected" error situations, rather than an uncaught server error. However, I do think the most appropriate thing to do here is let all these methods return
None
in addition to theList
/Tuple
. This would match the actual language server protocol wherenull
is a possible return type. But the change in return type would imply a breaking change so I'm not sure if that's something worthy of doing without a super compelling reason.Alternatively, we could also define a new
NotFoundError
and raise that error explicitly when the language server returnsnull
. If that's a preferred way to handle this situation, I'm happy to take that approach and update this PR.