1 /*
2  * Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3  */
4 
5 package kotlinx.serialization.hocon
6 
7 import com.typesafe.config.*
8 import kotlinx.serialization.*
9 
SerializerNotFoundExceptionnull10 internal fun SerializerNotFoundException(type: String?) = SerializationException(
11     "Polymorphic serializer was not found for " +
12             if (type == null) "missing class discriminator ('null')" else "class discriminator '$type'"
13 )
14 
15 internal inline fun <reified T> ConfigValueTypeCastException(valueOrigin: ConfigOrigin) = SerializationException(
16     "${valueOrigin.description()} required to be of type ${T::class.simpleName}."
17 )
18 
19 internal fun InvalidKeyKindException(value: ConfigValue) = SerializationException(
20     "Value of type '${value.valueType()}' can't be used in HOCON as a key in the map. " +
21             "It should have either primitive or enum kind."
22 )
23 
24 internal fun throwUnsupportedFormatException(serializerName: String): Nothing =
25     throw SerializationException("$serializerName is supported only in Hocon format.")
26