This is an automated email from the ASF dual-hosted git repository.

tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new fd55cda6115 kie-issues#879: On the new DMN Editor, deleting a Decision 
that's inside a Decision Service is breaking the Decision Service (#2142)
fd55cda6115 is described below

commit fd55cda611569df463c6c1b3e5837ac72eb604cb
Author: Tiago Bento <[email protected]>
AuthorDate: Mon Feb 5 09:26:10 2024 -0500

    kie-issues#879: On the new DMN Editor, deleting a Decision that's inside a 
Decision Service is breaking the Decision Service (#2142)
---
 packages/dmn-editor/src/diagram/Diagram.tsx        | 10 ++++----
 .../dmn-editor/src/mutations/addConnectedNode.ts   |  2 +-
 .../src/mutations/addDecisionToDecisionService.ts  | 12 +++++----
 .../dmn-editor/src/mutations/addEdgeWaypoint.ts    |  4 +--
 .../mutations/deleteDecisionFromDecisionService.ts |  6 +++--
 packages/dmn-editor/src/mutations/deleteEdge.ts    |  4 +--
 .../dmn-editor/src/mutations/deleteEdgeWaypoint.ts |  4 +--
 packages/dmn-editor/src/mutations/deleteNode.ts    | 30 ++++++++++++++++------
 .../src/mutations/renameItemDefinition.ts          |  4 +--
 ...pulateInputDataAndDecisionsOnDecisionService.ts |  2 +-
 .../src/mutations/repositionEdgeWaypoint.ts        |  4 +--
 .../dmn-editor/src/mutations/repositionNode.ts     |  6 ++---
 packages/dmn-editor/src/mutations/resizeNode.ts    |  4 +--
 .../mutations/updateDecisionServiceDividerLine.ts  |  4 +--
 .../dmn-editor/src/mutations/updateExpression.ts   |  8 +++---
 15 files changed, 61 insertions(+), 43 deletions(-)

diff --git a/packages/dmn-editor/src/diagram/Diagram.tsx 
b/packages/dmn-editor/src/diagram/Diagram.tsx
index d20a79b3234..3190545e09f 100644
--- a/packages/dmn-editor/src/diagram/Diagram.tsx
+++ b/packages/dmn-editor/src/diagram/Diagram.tsx
@@ -705,7 +705,7 @@ export const Diagram = React.forwardRef<DiagramRef, { 
container: React.RefObject
                   dmnObjectQName: node.data.dmnObjectQName,
                   dmnObjectId: node.data.dmnObject?.["@_id"],
                   nodeNature: nodeNatures[node.type as NodeType],
-                  mode: NodeDeletionMode.FORM_DRG_AND_ALL_DRDS,
+                  mode: NodeDeletionMode.FROM_DRG_AND_ALL_DRDS,
                 });
                 state.dispatch(state).diagram.setNodeStatus(node.id, {
                   selected: false,
@@ -876,7 +876,7 @@ export const Diagram = React.forwardRef<DiagramRef, { 
container: React.RefObject
                     definitions: state.dmn.model.definitions,
                     drdIndex: state.diagram.drdIndex,
                     edge: { id: change.id, dmnObject: edge.data.dmnObject },
-                    mode: EdgeDeletionMode.FORM_DRG_AND_ALL_DRDS,
+                    mode: EdgeDeletionMode.FROM_DRG_AND_ALL_DRDS,
                   });
                   state.dispatch(state).diagram.setEdgeStatus(change.id, { 
selected: false, draggingWaypoint: false });
                 }
@@ -960,7 +960,7 @@ export const Diagram = React.forwardRef<DiagramRef, { 
container: React.RefObject
               definitions: state.dmn.model.definitions,
               drdIndex: state.diagram.drdIndex,
               edge: { id: oldEdge.id, dmnObject: oldEdge.data!.dmnObject },
-              mode: EdgeDeletionMode.FORM_DRG_AND_ALL_DRDS,
+              mode: EdgeDeletionMode.FROM_DRG_AND_ALL_DRDS,
             });
 
             const deletedWaypoints = 
deletedDmnEdgeOnCurrentDrd?.["di:waypoint"];
@@ -1492,7 +1492,7 @@ export function KeyboardShortcuts(props: {}) {
             definitions: state.dmn.model.definitions,
             drdIndex: state.diagram.drdIndex,
             edge: { id: edge.id, dmnObject: edge.data!.dmnObject },
-            mode: EdgeDeletionMode.FORM_DRG_AND_ALL_DRDS,
+            mode: EdgeDeletionMode.FROM_DRG_AND_ALL_DRDS,
           });
           state.dispatch(state).diagram.setEdgeStatus(edge.id, {
             selected: false,
@@ -1514,7 +1514,7 @@ export function KeyboardShortcuts(props: {}) {
                 dmnObjectQName: node.data.dmnObjectQName,
                 dmnObjectId: node.data.dmnObject?.["@_id"],
                 nodeNature: nodeNatures[node.type as NodeType],
-                mode: NodeDeletionMode.FORM_DRG_AND_ALL_DRDS,
+                mode: NodeDeletionMode.FROM_DRG_AND_ALL_DRDS,
               });
               state.dispatch(state).diagram.setNodeStatus(node.id, {
                 selected: false,
diff --git a/packages/dmn-editor/src/mutations/addConnectedNode.ts 
b/packages/dmn-editor/src/mutations/addConnectedNode.ts
index e356a302a68..769e536179a 100644
--- a/packages/dmn-editor/src/mutations/addConnectedNode.ts
+++ b/packages/dmn-editor/src/mutations/addConnectedNode.ts
@@ -146,7 +146,7 @@ export function addConnectedNode({
       })
     );
   } else {
-    throw new Error(`Unknown node usage '${nature}'.`);
+    throw new Error(`DMN MUTATION: Unknown node usage '${nature}'.`);
   }
 
   const newShapeId = generateUuid();
diff --git a/packages/dmn-editor/src/mutations/addDecisionToDecisionService.ts 
b/packages/dmn-editor/src/mutations/addDecisionToDecisionService.ts
index 7700e3bb0b2..f2d511238c8 100644
--- a/packages/dmn-editor/src/mutations/addDecisionToDecisionService.ts
+++ b/packages/dmn-editor/src/mutations/addDecisionToDecisionService.ts
@@ -42,12 +42,14 @@ export function addDecisionToDecisionService({
 
   const decision = definitions.drgElement?.find((s) => s["@_id"] === 
decisionId);
   if (decision?.__$$element !== "decision") {
-    throw new Error(`DRG Element with id '${decisionId}' is either not a 
Decision or doesn't exist.`);
+    throw new Error(`DMN MUTATION: DRG Element with id '${decisionId}' is 
either not a Decision or doesn't exist.`);
   }
 
   const decisionService = definitions.drgElement?.find((s) => s["@_id"] === 
decisionServiceId);
   if (decisionService?.__$$element !== "decisionService") {
-    throw new Error(`DRG Element with id '${decisionServiceId}' is either not 
a Decision Service or doesn't exist.`);
+    throw new Error(
+      `DMN MUTATION: DRG Element with id '${decisionServiceId}' is either not 
a Decision Service or doesn't exist.`
+    );
   }
 
   const diagram = addOrGetDrd({ definitions, drdIndex });
@@ -67,7 +69,7 @@ export function addDecisionToDecisionService({
     decisionService.outputDecision ??= [];
     decisionService.outputDecision.push({ "@_href": `#${decisionId}` });
   } else {
-    throw new Error(`Invalid section to add decision to: '${section}' `);
+    throw new Error(`DMN MUTATION: Invalid section to add decision to: 
'${section}' `);
   }
 
   repopulateInputDataAndDecisionsOnDecisionService({ definitions, 
decisionService });
@@ -84,7 +86,7 @@ export function getSectionForDecisionInsideDecisionService({
 }): "output" | "encapsulated" {
   if (!decisionShape?.["dc:Bounds"] || !decisionServiceShape?.["dc:Bounds"]) {
     throw new Error(
-      `Can't determine Decision Service section for Decision 
'${decisionShape["@_dmnElementRef"]}' because it doens't have a DMNShape.`
+      `DMN MUTATION: Can't determine Decision Service section for Decision 
'${decisionShape["@_dmnElementRef"]}' because it doens't have a DMNShape.`
     );
   }
 
@@ -99,7 +101,7 @@ export function getSectionForDecisionInsideDecisionService({
 
   if (!contaimentRelationship.isInside) {
     throw new Error(
-      `Decision '${decisionShape["@_dmnElementRef"]}' can't be added to 
Decision Service '${decisionServiceShape["@_dmnElementRef"]}' because its shape 
is not visually contained by the Decision Service's shape.`
+      `DMN MUTATION: Decision '${decisionShape["@_dmnElementRef"]}' can't be 
added to Decision Service '${decisionServiceShape["@_dmnElementRef"]}' because 
its shape is not visually contained by the Decision Service's shape.`
     );
   }
 
diff --git a/packages/dmn-editor/src/mutations/addEdgeWaypoint.ts 
b/packages/dmn-editor/src/mutations/addEdgeWaypoint.ts
index b19cd5af252..87735cf144d 100644
--- a/packages/dmn-editor/src/mutations/addEdgeWaypoint.ts
+++ b/packages/dmn-editor/src/mutations/addEdgeWaypoint.ts
@@ -37,12 +37,12 @@ export function addEdgeWaypoint({
 
   const diagramElement = diagramElements[edgeIndex];
   if (diagramElement.__$$element !== "dmndi:DMNEdge") {
-    throw new Error("Can't remove a waypoint from an element that is not a 
DMNEdge.");
+    throw new Error("DMN MUTATION: Can't remove a waypoint from an element 
that is not a DMNEdge.");
   }
 
   if (beforeIndex > (diagramElement["di:waypoint"]?.length ?? 0) - 1) {
     throw new Error(
-      `Can't add waypoint before index '${beforeIndex}' to DMNEdge 
'${diagramElement["@_id"]}' because the waypoint array is smaller than 
'beforeIndex' requires.`
+      `DMN MUTATION: Can't add waypoint before index '${beforeIndex}' to 
DMNEdge '${diagramElement["@_id"]}' because the waypoint array is smaller than 
'beforeIndex' requires.`
     );
   }
 
diff --git 
a/packages/dmn-editor/src/mutations/deleteDecisionFromDecisionService.ts 
b/packages/dmn-editor/src/mutations/deleteDecisionFromDecisionService.ts
index d632e380366..a22b078e334 100644
--- a/packages/dmn-editor/src/mutations/deleteDecisionFromDecisionService.ts
+++ b/packages/dmn-editor/src/mutations/deleteDecisionFromDecisionService.ts
@@ -33,12 +33,14 @@ export function deleteDecisionFromDecisionService({
 
   const decision = definitions.drgElement?.find((s) => s["@_id"] === 
decisionId);
   if (decision?.__$$element !== "decision") {
-    throw new Error(`DRG Element with id '${decisionId}' is either not a 
Decision or doesn't exist.`);
+    throw new Error(`DMN MUTATION: DRG Element with id '${decisionId}' is 
either not a Decision or doesn't exist.`);
   }
 
   const decisionService = definitions.drgElement?.find((s) => s["@_id"] === 
decisionServiceId);
   if (decisionService?.__$$element !== "decisionService") {
-    throw new Error(`DRG Element with id '${decisionServiceId}' is either not 
a Decision Service or doesn't exist.`);
+    throw new Error(
+      `DMN MUTATION: DRG Element with id '${decisionServiceId}' is either not 
a Decision Service or doesn't exist.`
+    );
   }
 
   decisionService.outputDecision = (decisionService.outputDecision ?? 
[]).filter(
diff --git a/packages/dmn-editor/src/mutations/deleteEdge.ts 
b/packages/dmn-editor/src/mutations/deleteEdge.ts
index 925779ea486..4399438ddd0 100644
--- a/packages/dmn-editor/src/mutations/deleteEdge.ts
+++ b/packages/dmn-editor/src/mutations/deleteEdge.ts
@@ -28,7 +28,7 @@ import { DmnDiagramEdgeData } from "../diagram/edges/Edges";
 import { repopulateInputDataAndDecisionsOnAllDecisionServices } from 
"./repopulateInputDataAndDecisionsOnDecisionService";
 
 export enum EdgeDeletionMode {
-  FORM_DRG_AND_ALL_DRDS,
+  FROM_DRG_AND_ALL_DRDS,
   FROM_CURRENT_DRD_ONLY,
 }
 
@@ -60,7 +60,7 @@ export function deleteEdge({
     throw new Error(`DMN MUTATION: Can't find DMN element with ID 
${edge.dmnObject.id}`);
   }
 
-  if (mode === EdgeDeletionMode.FORM_DRG_AND_ALL_DRDS) {
+  if (mode === EdgeDeletionMode.FROM_DRG_AND_ALL_DRDS) {
     const requirements =
       switchExpression(edge?.dmnObject.requirementType, {
         // Casting to DMN15__tDecision because if has all types of 
requirement, but not necessarily that's true.
diff --git a/packages/dmn-editor/src/mutations/deleteEdgeWaypoint.ts 
b/packages/dmn-editor/src/mutations/deleteEdgeWaypoint.ts
index 3709e679948..cf275118fe3 100644
--- a/packages/dmn-editor/src/mutations/deleteEdgeWaypoint.ts
+++ b/packages/dmn-editor/src/mutations/deleteEdgeWaypoint.ts
@@ -35,12 +35,12 @@ export function deleteEdgeWaypoint({
 
   const diagramElement = diagramElements[edgeIndex];
   if (diagramElement.__$$element !== "dmndi:DMNEdge") {
-    throw new Error("Can't remove a waypoint from an element that is not a 
DMNEdge.");
+    throw new Error("DMN MUTATION: Can't remove a waypoint from an element 
that is not a DMNEdge.");
   }
 
   if (waypointIndex > (diagramElement["di:waypoint"]?.length ?? 0) - 1) {
     throw new Error(
-      `Can't remove waypoint with index '${waypointIndex}' from DMNEdge 
'${diagramElement["@_id"]}' because it doesn't exist.`
+      `DMN MUTATION: Can't remove waypoint with index '${waypointIndex}' from 
DMNEdge '${diagramElement["@_id"]}' because it doesn't exist.`
     );
   }
 
diff --git a/packages/dmn-editor/src/mutations/deleteNode.ts 
b/packages/dmn-editor/src/mutations/deleteNode.ts
index 363fd2f4627..c9eef1eb81e 100644
--- a/packages/dmn-editor/src/mutations/deleteNode.ts
+++ b/packages/dmn-editor/src/mutations/deleteNode.ts
@@ -29,7 +29,7 @@ import { DrgEdge } from "../diagram/graph/graph";
 import { EdgeDeletionMode, deleteEdge } from "./deleteEdge";
 
 export enum NodeDeletionMode {
-  FORM_DRG_AND_ALL_DRDS,
+  FROM_DRG_AND_ALL_DRDS,
   FROM_CURRENT_DRD_ONLY,
 }
 
@@ -68,8 +68,9 @@ export function deleteNode({
     return { deletedDmnObject: undefined, deletedDmnShapeOnCurrentDrd: 
undefined };
   }
 
-  // A DRD doesn't necessarily renders all edges of the DRG, so we need to 
look for what DRG edges to delete when deleting a node from any DRD.
-  if (mode === NodeDeletionMode.FORM_DRG_AND_ALL_DRDS) {
+  if (mode === NodeDeletionMode.FROM_DRG_AND_ALL_DRDS) {
+    // Delete Edges
+    // A DRD doesn't necessarily renders all edges of the DRG, so we need to 
look for what DRG edges to delete when deleting a node from any DRD.
     const nodeId = buildXmlHref({ namespace: dmnObjectNamespace, id: 
dmnObjectId! });
     for (let i = 0; i < drgEdges.length; i++) {
       const drgEdge = drgEdges[i];
@@ -78,7 +79,7 @@ export function deleteNode({
         deleteEdge({
           definitions,
           drdIndex,
-          mode: EdgeDeletionMode.FORM_DRG_AND_ALL_DRDS,
+          mode: EdgeDeletionMode.FROM_DRG_AND_ALL_DRDS,
           edge: {
             id: drgEdge.id,
             dmnObject: drgEdge.dmnObject,
@@ -86,6 +87,18 @@ export function deleteNode({
         });
       }
     }
+
+    // Delete from containing Decision Services
+    const drgElements = definitions.drgElement ?? [];
+    for (let i = 0; i < drgElements.length; i++) {
+      const drgElement = drgElements[i];
+      if (drgElement.__$$element !== "decisionService") {
+        continue;
+      }
+
+      drgElement.outputDecision = drgElement.outputDecision?.filter((od) => 
od["@_href"] !== nodeId);
+      drgElement.encapsulatedDecision = 
drgElement.encapsulatedDecision?.filter((ed) => ed["@_href"] !== nodeId);
+    }
   }
 
   let dmnObject: Unpacked<DMN15__tDefinitions["drgElement" | "artifact"]> | 
undefined;
@@ -94,20 +107,20 @@ export function deleteNode({
   if (!dmnObjectQName.prefix) {
     // Delete the dmnObject itself
     if (nodeNature === NodeNature.ARTIFACT) {
-      if (mode === NodeDeletionMode.FORM_DRG_AND_ALL_DRDS) {
+      if (mode === NodeDeletionMode.FROM_DRG_AND_ALL_DRDS) {
         const nodeIndex = (definitions.artifact ?? []).findIndex((a) => 
a["@_id"] === dmnObjectId);
         dmnObject = definitions.artifact?.splice(nodeIndex, 1)?.[0];
       }
     } else if (nodeNature === NodeNature.DRG_ELEMENT) {
       const nodeIndex = (definitions.drgElement ?? []).findIndex((d) => 
d["@_id"] === dmnObjectId);
       dmnObject =
-        mode === NodeDeletionMode.FORM_DRG_AND_ALL_DRDS
+        mode === NodeDeletionMode.FROM_DRG_AND_ALL_DRDS
           ? definitions.drgElement?.splice(nodeIndex, 1)?.[0]
           : definitions.drgElement?.[nodeIndex];
     } else if (nodeNature === NodeNature.UNKNOWN) {
       // Ignore. There's no dmnObject here.
     } else {
-      throw new Error(`Unknown node nature '${nodeNature}'.`);
+      throw new Error(`DMN MUTATION: Unknown node nature '${nodeNature}'.`);
     }
 
     if (!dmnObject) {
@@ -151,7 +164,7 @@ export function deleteNode({
   repopulateInputDataAndDecisionsOnAllDecisionServices({ definitions });
 
   return {
-    deletedDmnObject: mode === NodeDeletionMode.FORM_DRG_AND_ALL_DRDS ? 
dmnObject : undefined,
+    deletedDmnObject: mode === NodeDeletionMode.FROM_DRG_AND_ALL_DRDS ? 
dmnObject : undefined,
     deletedDmnShapeOnCurrentDrd,
   };
 }
@@ -171,6 +184,7 @@ export function canRemoveNodeFromDrdOnly({
 
   const dmnObjectHref = buildXmlHref({ namespace: dmnObjectNamespace, id: 
dmnObjectId! });
 
+  // FIXME: Tiago --> A Decision can be contained by more than one Decision 
Service.
   const containingDecisionService = definitions.drgElement?.find(
     (drgElement) =>
       drgElement.__$$element === "decisionService" &&
diff --git a/packages/dmn-editor/src/mutations/renameItemDefinition.ts 
b/packages/dmn-editor/src/mutations/renameItemDefinition.ts
index 5378afa0277..e18ce3df4a6 100644
--- a/packages/dmn-editor/src/mutations/renameItemDefinition.ts
+++ b/packages/dmn-editor/src/mutations/renameItemDefinition.ts
@@ -38,12 +38,12 @@ export function renameItemDefinition({
 }) {
   const dataType = allDataTypesById.get(itemDefinitionId);
   if (!dataType) {
-    throw new Error(`Can't rename unnexistent item definition. ID 
${itemDefinitionId}`);
+    throw new Error(`DMN MUTATION: Can't rename unnexistent item definition. 
ID ${itemDefinitionId}`);
   }
 
   if (dataType.namespace !== definitions["@_namespace"]) {
     throw new Error(
-      `Can't rename an external item definition. ID ${itemDefinitionId}, 
Namespace: ${dataType.namespace}`
+      `DMN MUTATION: Can't rename an external item definition. ID 
${itemDefinitionId}, Namespace: ${dataType.namespace}`
     );
   }
 
diff --git 
a/packages/dmn-editor/src/mutations/repopulateInputDataAndDecisionsOnDecisionService.ts
 
b/packages/dmn-editor/src/mutations/repopulateInputDataAndDecisionsOnDecisionService.ts
index e99345d1de0..75db1eb61b1 100644
--- 
a/packages/dmn-editor/src/mutations/repopulateInputDataAndDecisionsOnDecisionService.ts
+++ 
b/packages/dmn-editor/src/mutations/repopulateInputDataAndDecisionsOnDecisionService.ts
@@ -80,7 +80,7 @@ export function 
repopulateInputDataAndDecisionsOnDecisionService({
     } else if (r.type === "decisionIr") {
       inputDecisions.add(r.href);
     } else {
-      throw new Error(`Invalid type of element to be referenced by 
DecisionService: '${r.type}'`);
+      throw new Error(`DMN MUTATION: Invalid type of element to be referenced 
by DecisionService: '${r.type}'`);
     }
   }
 
diff --git a/packages/dmn-editor/src/mutations/repositionEdgeWaypoint.ts 
b/packages/dmn-editor/src/mutations/repositionEdgeWaypoint.ts
index 1ac07f8eff4..cceaa1377ac 100644
--- a/packages/dmn-editor/src/mutations/repositionEdgeWaypoint.ts
+++ b/packages/dmn-editor/src/mutations/repositionEdgeWaypoint.ts
@@ -37,12 +37,12 @@ export function repositionEdgeWaypoint({
 
   const diagramElement = diagramElements[edgeIndex];
   if (diagramElement.__$$element !== "dmndi:DMNEdge") {
-    throw new Error("Can't remove a waypoint from an element that is not a 
DMNEdge.");
+    throw new Error("DMN MUTATION: Can't remove a waypoint from an element 
that is not a DMNEdge.");
   }
 
   if (waypointIndex > (diagramElement["di:waypoint"]?.length ?? 0) - 1) {
     throw new Error(
-      `Can't reposition waypoint with index '${waypointIndex}' from DMNEdge 
'${diagramElement["@_id"]}' because it doesn't exist.`
+      `DMN MUTATION: Can't reposition waypoint with index '${waypointIndex}' 
from DMNEdge '${diagramElement["@_id"]}' because it doesn't exist.`
     );
   }
 
diff --git a/packages/dmn-editor/src/mutations/repositionNode.ts 
b/packages/dmn-editor/src/mutations/repositionNode.ts
index 478e0a74116..bc66387cdc6 100644
--- a/packages/dmn-editor/src/mutations/repositionNode.ts
+++ b/packages/dmn-editor/src/mutations/repositionNode.ts
@@ -63,7 +63,7 @@ export function repositionNode({
   const shape = diagramElements?.[change.shapeIndex] as DMNDI15__DMNShape | 
undefined;
   const shapeBounds = shape?.["dc:Bounds"];
   if (!shapeBounds) {
-    throw new Error("Cannot reposition non-existent shape bounds");
+    throw new Error("DMN MUTATION: Cannot reposition non-existent shape 
bounds");
   }
 
   let deltaX: number;
@@ -79,14 +79,14 @@ export function repositionNode({
     shapeBounds["@_x"] += change.offset.deltaX;
     shapeBounds["@_y"] += change.offset.deltaY;
   } else {
-    throw new Error(`Unknown type of node position change '${(change as 
any).type}'.`);
+    throw new Error(`DMN MUTATION: Unknown type of node position change 
'${(change as any).type}'.`);
   }
 
   const offsetEdges = (args: { edgeIndexes: number[]; waypoint: "last" | 
"first" }) => {
     for (const edgeIndex of args.edgeIndexes) {
       const edge = diagramElements[edgeIndex] as DMNDI15__DMNEdge | undefined;
       if (!edge || !edge["di:waypoint"]) {
-        throw new Error("Cannot reposition non-existent edge");
+        throw new Error("DMN MUTATION: Cannot reposition non-existent edge");
       }
 
       const isEdgeSelected = 
change.selectedEdges.indexOf(edge["@_dmnElementRef"]!) >= 0;
diff --git a/packages/dmn-editor/src/mutations/resizeNode.ts 
b/packages/dmn-editor/src/mutations/resizeNode.ts
index 00bd56d18ea..706792cec3d 100644
--- a/packages/dmn-editor/src/mutations/resizeNode.ts
+++ b/packages/dmn-editor/src/mutations/resizeNode.ts
@@ -61,7 +61,7 @@ export function resizeNode({
   const shape = diagramElements?.[change.shapeIndex] as DMNDI15__DMNShape | 
undefined;
   const shapeBounds = shape?.["dc:Bounds"];
   if (!shapeBounds) {
-    throw new Error("Cannot resize non-existent shape bounds");
+    throw new Error("DMN MUTATION: Cannot resize non-existent shape bounds");
   }
 
   const limit = { x: 0, y: 0 };
@@ -125,7 +125,7 @@ export function resizeNode({
 
       const edge = diagramElements[edgeIndex] as DMNDI15__DMNEdge | undefined;
       if (!edge || !edge["di:waypoint"]) {
-        throw new Error("Cannot reposition non-existent edge");
+        throw new Error("DMN MUTATION: Cannot reposition non-existent edge");
       }
 
       const waypoint = switchExpression(args.waypointSelector, {
diff --git 
a/packages/dmn-editor/src/mutations/updateDecisionServiceDividerLine.ts 
b/packages/dmn-editor/src/mutations/updateDecisionServiceDividerLine.ts
index 15fc0f6c504..88fb40d7bde 100644
--- a/packages/dmn-editor/src/mutations/updateDecisionServiceDividerLine.ts
+++ b/packages/dmn-editor/src/mutations/updateDecisionServiceDividerLine.ts
@@ -54,12 +54,12 @@ export function updateDecisionServiceDividerLine({
   const shape = diagramElements?.[shapeIndex] as DMNDI15__DMNShape | undefined;
   const shapeBounds = shape?.["dc:Bounds"];
   if (!shapeBounds) {
-    throw new Error("Cannot reposition divider line of non-existent shape 
bounds");
+    throw new Error("DMN MUTATION: Cannot reposition divider line of 
non-existent shape bounds");
   }
 
   const ds = definitions.drgElement![drgElementIndex] as 
DMN15__tDecisionService;
   if (!ds) {
-    throw new Error("Cannot reposition divider line of non-existent Decision 
Service");
+    throw new Error("DMN MUTATION: Cannot reposition divider line of 
non-existent Decision Service");
   }
 
   const decisionMinSizes = MIN_NODE_SIZES[NODE_TYPES.decision](snapGrid);
diff --git a/packages/dmn-editor/src/mutations/updateExpression.ts 
b/packages/dmn-editor/src/mutations/updateExpression.ts
index 7a028e7bbbf..74e4b86c62b 100644
--- a/packages/dmn-editor/src/mutations/updateExpression.ts
+++ b/packages/dmn-editor/src/mutations/updateExpression.ts
@@ -42,7 +42,7 @@ export function updateExpression({
 
   const drgElement = definitions.drgElement?.[drgElementIndex];
   if (!drgElement) {
-    throw new Error("Can't update expression for drgElement that doesn't 
exist.");
+    throw new Error("DMN MUTATION: Can't update expression for drgElement that 
doesn't exist.");
   }
 
   renameDrgElement({
@@ -56,11 +56,11 @@ export function updateExpression({
     drgElement.variable!["@_typeRef"] = updatedExpression?.["@_typeRef"] ?? 
drgElement.variable!["@_typeRef"];
   } else if (drgElement?.__$$element === "businessKnowledgeModel") {
     if (expression.logicType !== ExpressionDefinitionLogicType.Function) {
-      throw new Error("Can't have an expression on a BKM that is not a 
Function.");
+      throw new Error("DMN MUTATION: Can't have an expression on a BKM that is 
not a Function.");
     }
 
     if (!updatedExpression?.__$$element) {
-      throw new Error("Can't determine expression type without its __$$element 
property.");
+      throw new Error("DMN MUTATION: Can't determine expression type without 
its __$$element property.");
     }
 
     // We remove the __$$element here, because otherwise the 
"functionDefinition" element name will be used in the final XML.
@@ -68,7 +68,7 @@ export function updateExpression({
     drgElement.encapsulatedLogic = _updateExpression as 
DMN15__tFunctionDefinition;
     drgElement.variable!["@_typeRef"] = _updateExpression?.["@_typeRef"] ?? 
drgElement.variable!["@_typeRef"];
   } else {
-    throw new Error("Can't update expression for drgElement that is not a 
Decision or a BKM.");
+    throw new Error("DMN MUTATION: Can't update expression for drgElement that 
is not a Decision or a BKM.");
   }
 
   const { widthsExtension, widths } = addOrGetDrd({ definitions, drdIndex });


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to