Skip to content

Commit 92af0db

Browse files
Improve error handling in DataMapperView for position data retrieval
1 parent 1b7ff36 commit 92af0db

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

workspaces/ballerina/ballerina-visualizer/src/views/DataMapper/DataMapperView.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,14 @@ export function DataMapperView(props: DataMapperProps) {
370370
targetField: targetField,
371371
index: index
372372
});
373-
return position;
373+
if (position) {
374+
return position;
375+
} else {
376+
throw new Error("Clause position not found");
377+
}
374378
} catch (error) {
375379
console.error(error);
380+
return { line: 0, offset: 0 };
376381
}
377382
}
378383

@@ -548,7 +553,12 @@ export function DataMapperView(props: DataMapperProps) {
548553
codedata: viewState.codedata,
549554
targetField: viewId
550555
})
551-
// TODO: need to handle undfined property case
556+
557+
if (!property?.codedata?.lineRange?.startLine) {
558+
console.error("Failed to get start line for generating unique name");
559+
return name;
560+
}
561+
552562
const completions = await rpcClient.getBIDiagramRpcClient().getDataMapperCompletions({
553563
filePath,
554564
context: {

0 commit comments

Comments
 (0)