From 92bc3ebd005aebd7a9e46b663b99a57e35529bc7 Mon Sep 17 00:00:00 2001 From: Johannes Wienke Date: Wed, 24 May 2023 10:05:47 +0200 Subject: [PATCH] fix(model-server-lib): don't throw exceptions for missing children Restore the old behavior of allow to query non-existing children similar to what has been done in MODELIX-435 for references. Fixes: MODELIX-444 --- .../org/modelix/model/server/light/QueryImplementation.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/model-server-lib/src/main/kotlin/org/modelix/model/server/light/QueryImplementation.kt b/model-server-lib/src/main/kotlin/org/modelix/model/server/light/QueryImplementation.kt index 3aa7316105..0c91bf547e 100644 --- a/model-server-lib/src/main/kotlin/org/modelix/model/server/light/QueryImplementation.kt +++ b/model-server-lib/src/main/kotlin/org/modelix/model/server/light/QueryImplementation.kt @@ -47,7 +47,11 @@ fun RootOrSubquery.queryNodes(node: INode): Sequence { return when (this) { is QueryAllChildren -> node.allChildren.asSequence() is QueryAncestors -> node.getAncestors(false) - is QueryChildren -> node.getChildren(this.role).asSequence() + is QueryChildren -> try { + node.getChildren(this.role).asSequence() + } catch (e: RuntimeException) { + emptySequence() + } is QueryDescendants -> node.getDescendants(false) is QueryParent -> listOfNotNull(node.parent).asSequence() is QueryReference -> {