From 746d87df0d0873a7f4973aa5d1c9b8549df38b55 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Mon, 4 Oct 2021 11:06:47 +0200 Subject: [PATCH] make excpetion handling understandable --- .../src/main/kotlin/theodolite/patcher/PatcherFactory.kt | 6 +++--- .../theodolite/util/InvalidPatcherConfigurationException.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt b/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt index 9350cecc4..cdf115a07 100644 --- a/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt +++ b/theodolite/src/main/kotlin/theodolite/patcher/PatcherFactory.kt @@ -32,7 +32,7 @@ class PatcherFactory { k8sResources.filter { it.first == patcherDefinition.resource } .map { resource -> resource.second } .firstOrNull() - ?: throw DeploymentFailedException("Could not find resource ${patcherDefinition.resource}") + ?: throw InvalidPatcherConfigurationException("Could not find resource ${patcherDefinition.resource}") return try { when (patcherDefinition.type) { @@ -86,10 +86,10 @@ class PatcherFactory { ) else -> throw InvalidPatcherConfigurationException("Patcher type ${patcherDefinition.type} not found.") } - } catch (e: Exception) { + } catch (e: NullPointerException) { throw InvalidPatcherConfigurationException( "Could not create patcher with type ${patcherDefinition.type}" + - " Probably a required patcher argument was not specified." + " Probably a required patcher argument was not specified.", e ) } } diff --git a/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt b/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt index e8ecd11d5..81ea227d0 100644 --- a/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt +++ b/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt @@ -1,4 +1,4 @@ package theodolite.util -class InvalidPatcherConfigurationException(message: String) : Exception(message) +class InvalidPatcherConfigurationException(message: String, e: Exception? = null) : Exception(message, e) -- GitLab