diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/environment/EnvironmentSetup.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/environment/EnvironmentSetup.kt index 729096de612f54afba63406b374b6a6aeb3f74b5..63f9235404bf6c1bc832c23d0c1785d61f65f5da 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/environment/EnvironmentSetup.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/environment/EnvironmentSetup.kt @@ -86,17 +86,24 @@ class EnvironmentSetup @Inject constructor( val targetEnvKey = if (environmentJson.has(currentEnvironment.rawKey)) { currentEnvironment.rawKey } else { - Timber.e("Tried to use unavailable environment: $variableKey on $currentEnvironment") + Timber.e("Tried to use unavailable environment: $currentEnvironment") Type.PRODUCTION.rawKey } - environmentJson + + val value = environmentJson .getAsJsonObject(targetEnvKey) .getAsJsonPrimitive(variableKey.rawKey) + + return@run if (value != null) { + Timber.v("getEnvironmentValue(endpoint=%s): %s", variableKey, value) + value + } else { + throw IllegalStateException("$currentEnvironment:$variableKey is missing in your *_environment.json") + } } catch (e: Exception) { - Timber.e(e, "Failed to retrieve endpoint URL for $currentEnvironment:$variableKey") - throw IllegalStateException("Failed to setup test environment", e) + throw IllegalStateException("Failed to retrieve $currentEnvironment:$variableKey", e) } - }.also { Timber.v("getEndpointUrl(endpoint=%s): %s", variableKey, it) } + } val submissionCdnUrl: String get() = getEnvironmentValue(SUBMISSION).asString