From 069a41348f48cd5db58dbda9759c414414d0d612 Mon Sep 17 00:00:00 2001 From: Charukesh Date: Fri, 13 Nov 2026 23:48:22 +0530 Subject: [PATCH] fix(concerto-core): throw IllegalModelException in getNestedProperty for primitive or enum Closes #1627 Signed-off-by: Charukesh --- packages/concerto-core/src/introspect/classdeclaration.ts | 2 +- packages/concerto-core/test/introspect/classdeclaration.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/concerto-core/src/introspect/classdeclaration.ts b/packages/concerto-core/src/introspect/classdeclaration.ts index e86fba57a9..9b47029f61 100644 --- a/packages/concerto-core/src/introspect/classdeclaration.ts +++ b/packages/concerto-core/src/introspect/classdeclaration.ts @@ -590,7 +590,7 @@ class ClassDeclaration extends Declaration { // not the last element, get the class of the element if (n < propertyNames.length - 1) { if (result.isPrimitive() || result.isTypeEnum()) { - throw new Error('Property ' + propertyNames[n] + ' is a primitive or enum. Invalid property path: ' + propertyPath); + throw new IllegalModelException('Property ' + propertyNames[n] + ' is a primitive or enum. Invalid property path: ' + propertyPath, this.modelFile, this.ast.location); } else { // get the nested type, this throws if the type is missing or if the type is an enum classDeclaration = classDeclaration.getModelFile().getModelManager().getType(result.getFullyQualifiedTypeName()); diff --git a/packages/concerto-core/test/introspect/classdeclaration.js b/packages/concerto-core/test/introspect/classdeclaration.js index 009cd4b841..acda1dfd16 100644 --- a/packages/concerto-core/test/introspect/classdeclaration.js +++ b/packages/concerto-core/test/introspect/classdeclaration.js @@ -277,7 +277,7 @@ describe('ClassDeclaration', () => { }); it('get error with primitives', function() { let extremeOuter = modelManager.getType('com.hyperledger.testing@1.0.0.ExtremeOuter'); - (()=>{extremeOuter.getNestedProperty('outerAsset.int.innerAsset');}).should.throw(/Property int is a primitive or enum/); + (()=>{extremeOuter.getNestedProperty('outerAsset.int.innerAsset');}).should.throw(IllegalModelException, /Property int is a primitive or enum/); }); });