Skip to content

Commit

Permalink
Improve the document cache miss error message (#2161)
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Feb 18, 2022
1 parent 5852ba4 commit 484c052
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilly-birds-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"graphql-language-service-server": patch
"graphql-language-service": patch
---

Do not log errors when a JS/TS file has no embedded graphql tags
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export class MessageProcessor {

const cachedDocument = this._getCachedDocument(textDocument.uri);
if (!cachedDocument) {
throw new Error('A cached document cannot be found.');
return [];
}

const found = cachedDocument.contents.find(content => {
Expand Down Expand Up @@ -537,7 +537,7 @@ export class MessageProcessor {

const cachedDocument = this._getCachedDocument(textDocument.uri);
if (!cachedDocument) {
throw new Error('A cached document cannot be found.');
return { contents: [] };
}

const found = cachedDocument.contents.find(content => {
Expand Down Expand Up @@ -749,8 +749,9 @@ export class MessageProcessor {
const textDocument = params.textDocument;
const cachedDocument = this._getCachedDocument(textDocument.uri);
if (!cachedDocument || !cachedDocument.contents[0]) {
throw new Error('A cached document cannot be found.');
return [];
}

return this._languageService.getDocumentSymbols(
cachedDocument.contents[0].query,
textDocument.uri,
Expand Down

2 comments on commit 484c052

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.