[aia-eval] better diagnostic on config deserialization

GitOrigin-RevId: a993ec187e38c65bda6c0adacefedc99c2ec28e6
This commit is contained in:
anton.spilnyy
2024-09-20 11:05:19 +02:00
committed by intellij-monorepo-bot
parent f7abd34680
commit 9c4ca2e38b

View File

@@ -4,14 +4,14 @@ package com.intellij.cce.util
inline fun <reified T> Map<String, *>.getAs(key: String): T {
check(key in this.keys) { "$key not found. Existing keys: ${keys.toList()}" }
val value = this.getValue(key)
check(value is T) { "Unexpected type in config" }
check(value is T) { "Unexpected type of key <$key> in config" }
return value
}
inline fun <reified T> Map<String, *>.getIfExists(key: String): T? {
if (key !in this.keys) return null
val value = this.getValue(key)
check(value is T) { "Unexpected type in config" }
check(value is T) { "Unexpected type of key <$key> in config" }
return value
}