diff --git a/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt b/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt index d3a6bc2..d125635 100644 --- a/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt +++ b/BankingPersistence/src/commonMain/kotlin/net/codinux/banking/persistence/SqliteBankingRepository.kt @@ -37,6 +37,13 @@ expect fun createSqlDriverDriver(dbName: String, schema: SqlSchema> mapEnum(enum: Enum): String = enum.name private fun > mapToEnum(enumName: String, values: EnumEntries): E = - values.first { it.name == enumName } + try { + values.first { it.name == enumName } + } catch (e: Throwable) { + log.error(e) { "Could not map enumName '$enumName' to ${values.first()::class}"} + throw e + } + + + private fun > mapToEnum(enumName: String, values: EnumEntries, enumNamesToMigrate: Map): E = + mapToEnum(enumNamesToMigrate[enumName] ?: enumName, values) private fun > mapToEnumNullable(enumName: String, values: EnumEntries): E? { val mapped = values.firstOrNull { it.name == enumName }