From d6b647c23832c3338e40c20ae1593d75b32e5642 Mon Sep 17 00:00:00 2001
From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de>
Date: Wed, 2 Jun 2021 22:40:08 +0200
Subject: [PATCH] Throw exception if load or resource type not found

---
 .../kotlin/theodolite/patcher/PatcherDefinitionFactory.kt    | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt
index bcb568f71..d5a6f3821 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherDefinitionFactory.kt
@@ -21,8 +21,7 @@ class PatcherDefinitionFactory {
      *     value of the requiredType.
      */
     fun createPatcherDefinition(requiredType: String, patcherTypes: List<TypeName>): List<PatcherDefinition> {
-        return patcherTypes
-            .filter { type -> type.typeName == requiredType }
-            .flatMap { type -> type.patchers }
+        return patcherTypes.firstOrNull() { type -> type.typeName == requiredType }
+            ?.patchers ?: throw IllegalArgumentException("typeName $requiredType not found.")
     }
 }
-- 
GitLab