From 44db1cab353a8f3412673697e66326f82f08fc6d Mon Sep 17 00:00:00 2001 From: anquetil Date: Sat, 4 Jan 2025 16:23:28 +0100 Subject: [PATCH] Catching the SlotNotFound error and added a comment to help users debug --- src/Fame-Core/FMRelationSlot.class.st | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Fame-Core/FMRelationSlot.class.st b/src/Fame-Core/FMRelationSlot.class.st index aa078246..8f52b98a 100644 --- a/src/Fame-Core/FMRelationSlot.class.st +++ b/src/Fame-Core/FMRelationSlot.class.st @@ -50,7 +50,19 @@ FMRelationSlot >> addAssociationFrom: ownerObject to: otherObject [ association may have to be removed first." | realInverseSlot | - realInverseSlot := self realInverseSlotFor: otherObject. + + [ + realInverseSlot := self realInverseSlotFor: otherObject + ] on: SlotNotFound + do: [ :err | + "The reverse slot was not found. + To investigate the problem, inspect: + - ownerObject -- The object which relation is set + - otherObject == The object which is set in the relation + - `self name` -- The name of the relation in ownerObject that is set to otherObject + - `self targetClass` -- The expected type for otherObject" + self halt. + ]. realInverseSlot isToOne ifTrue: [ (realInverseSlot read: otherObject) ifNotNil: [ :oldObject | realInverseSlot removeAssociationFrom: otherObject to: oldObject ].