From 4c73d750dbb3c022745b3558d1794775fcd2ce66 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Fri, 6 Dec 2024 11:07:57 -0500 Subject: [PATCH] Error catchers for resolvers Signed-off-by: worksofliam --- extension/server/src/connection.ts | 42 +++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/extension/server/src/connection.ts b/extension/server/src/connection.ts index 5beef8bc..0e10e86c 100644 --- a/extension/server/src/connection.ts +++ b/extension/server/src/connection.ts @@ -63,15 +63,23 @@ export async function memberResolve(baseUri: string, member: string, file: strin if (resolvedMembers[baseUri] && resolvedMembers[baseUri][fileKey]) return resolvedMembers[baseUri][fileKey]; - const resolvedMember = await queue.add(() => {return connection.sendRequest("memberResolve", [member, file])}) as IBMiMember|undefined; - // const resolvedMember = await connection.sendRequest("memberResolve", [member, file]) as IBMiMember|undefined; - - if (resolvedMember) { - if (!resolvedMembers[baseUri]) resolvedMembers[baseUri] = {}; - resolvedMembers[baseUri][fileKey] = resolvedMember; + try { + const resolvedMember = await queue.add(() => {return connection.sendRequest("memberResolve", [member, file])}) as IBMiMember|undefined; + // const resolvedMember = await connection.sendRequest("memberResolve", [member, file]) as IBMiMember|undefined; + + if (resolvedMember) { + if (!resolvedMembers[baseUri]) resolvedMembers[baseUri] = {}; + resolvedMembers[baseUri][fileKey] = resolvedMember; + } + + return resolvedMember; + } catch (e) { + console.log(`Member resolve failed.`); + console.log(JSON.stringify({baseUri, member, file})); + console.log(e); } - return resolvedMember; + return undefined; } export async function streamfileResolve(baseUri: string, base: string[]): Promise { @@ -82,15 +90,23 @@ export async function streamfileResolve(baseUri: string, base: string[]): Promis const paths = (workspace ? includePath[workspace.uri] : []) || []; - const resolvedPath = await queue.add(() => {return connection.sendRequest("streamfileResolve", [base, paths])}) as string|undefined; - // const resolvedPath = await connection.sendRequest("streamfileResolve", [base, paths]) as string|undefined; + try { + const resolvedPath = await queue.add(() => {return connection.sendRequest("streamfileResolve", [base, paths])}) as string|undefined; + // const resolvedPath = await connection.sendRequest("streamfileResolve", [base, paths]) as string|undefined; + + if (resolvedPath) { + if (!resolvedStreamfiles[baseUri]) resolvedStreamfiles[baseUri] = {}; + resolvedStreamfiles[baseUri][baseString] = resolvedPath; + } - if (resolvedPath) { - if (!resolvedStreamfiles[baseUri]) resolvedStreamfiles[baseUri] = {}; - resolvedStreamfiles[baseUri][baseString] = resolvedPath; + return resolvedPath; + } catch (e) { + console.log(`Streamfile resolve failed.`); + console.log(JSON.stringify({baseUri, base, paths})); + console.log(e); } - return resolvedPath; + return undefined; } export function getWorkingDirectory(): Promise {