Commit 2c76df90 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix alpha char missing crash. Will now place Z!

parent bc25572e
Pipeline #15892 failed with stages
in 10 minutes and 4 seconds
......@@ -19,13 +19,14 @@
package org.memobase.helpers
import com.beust.klaxon.JsonObject
import org.apache.logging.log4j.LogManager
import org.memobase.KEYS
/**
* Helper functions to build hierarchical facet values for places and persons.
*/
object FacetBuildHelpers {
private val log = LogManager.getLogger("FacetBuildHelper")
private const val separator = "~"
private const val level1 = "0"
......@@ -80,7 +81,12 @@ object FacetBuildHelpers {
private fun getCapitalLetter(name: String): Char {
val foldedName = AsciiFolder.foldToASCII(name)
val firstChar = foldedName.first { isAlphaChar.matches(it.toString()) }
return firstChar.toUpperCase()
return try {
val firstChar = foldedName.first { isAlphaChar.matches(it.toString()) }
firstChar.toUpperCase()
} catch (ex: NoSuchElementException) {
log.error("The name does not contain a valid alpha character: $foldedName.")
'Z'
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment