jvmMain.dev.programadorthi.routing.statuspages.StatusPagesUtilsJvm.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of status-pages-jvm Show documentation
Show all versions of status-pages-jvm Show documentation
A basic port to https://ktor.io/docs/server-status-pages.html
The newest version!
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package dev.programadorthi.routing.statuspages
import kotlin.reflect.KClass
internal actual fun selectNearestParentClass(
cause: Throwable,
keys: List>,
): KClass<*>? = keys.minByOrNull { distance(cause.javaClass, it.java) }
private fun distance(
child: Class<*>,
parent: Class<*>,
): Int {
var result = 0
var current = child
while (current != parent) {
current = current.superclass
result++
}
return result
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy