diff --git a/CHANGELOG.md b/CHANGELOG.md index 06178dc..333ba64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [2.6.1] - 2024-08-30 +- Fix issue [#344](https://github.com/intersystems/language-server/issues/344): Prevent errors during hover when no data was returned from the server + ## [2.6.0] - 2024-08-29 - Fix issue [#329](https://github.com/intersystems/language-server/issues/329): Support Unix platforms that don't have the `en_US.UTF-8` locale - Fix issue [#336](https://github.com/intersystems/language-server/issues/336): Add intellisense for variables set to the returned value of a method, or a property, with a declared type diff --git a/client/src/makeRESTRequest.ts b/client/src/makeRESTRequest.ts index 1eb3167..5ba9bd6 100644 --- a/client/src/makeRESTRequest.ts +++ b/client/src/makeRESTRequest.ts @@ -256,7 +256,13 @@ export async function makeRESTRequest(method: "GET"|"POST", api: number, path: s return respdata; } } catch (error) { - console.log(error); + client.warn(`Error making REST request ${method} ${path}: ${ + typeof error == "string" + ? error + : error instanceof Error + ? error.toString() + : JSON.stringify(error) + }`); return undefined; } }; diff --git a/server/src/providers/hover.ts b/server/src/providers/hover.ts index c3f32ec..51c9956 100644 --- a/server/src/providers/hover.ts +++ b/server/src/providers/hover.ts @@ -91,7 +91,7 @@ export async function onHover(params: TextDocumentPositionParams): Promise 0) { + if (Array.isArray(exprespdata?.data?.result?.content?.expansion) && exprespdata.data.result.content.expansion.length > 0) { // We got data back const exptext = exprespdata.data.result.content.expansion.join(" \n"); if (exptext.slice(0,5) === "ERROR") { @@ -324,7 +324,7 @@ export async function onHover(params: TextDocumentPositionParams): Promise 0) { + if (Array.isArray(defrespdata?.data?.result?.content?.definition) && defrespdata.data.result.content.definition.length > 0) { // The macro definition was found return { contents: macroDefToDoc(defrespdata.data.result.content.definition), @@ -357,7 +357,7 @@ export async function onHover(params: TextDocumentPositionParams): Promise 0) { + if (Array.isArray(respdata?.data?.result?.content?.definition) && respdata.data.result.content.definition.length > 0) { // The macro definition was found return { contents: macroDefToDoc(respdata.data.result.content.definition), @@ -902,7 +902,7 @@ export async function onHover(params: TextDocumentPositionParams): Promise