org.jetbrains.kotlinx.jupyter.codegen.ThrowableRenderersProcessorImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jupyter-kernel Show documentation
Show all versions of kotlin-jupyter-kernel Show documentation
Kotlin Jupyter kernel published as artifact
package org.jetbrains.kotlinx.jupyter.codegen
import org.jetbrains.kotlinx.jupyter.api.ThrowableRenderer
import org.jetbrains.kotlinx.jupyter.exceptions.LibraryProblemPart
import org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryException
import org.jetbrains.kotlinx.jupyter.exceptions.rethrowAsLibraryException
class ThrowableRenderersProcessorImpl : ThrowableRenderersProcessor {
private val renderers = mutableListOf()
override fun renderThrowable(throwable: Throwable): Any? {
return try {
rethrowAsLibraryException(LibraryProblemPart.THROWABLE_RENDERERS) {
renderers.firstOrNull { it.accepts(throwable) }?.render(throwable)
}
} catch (ex: ReplLibraryException) {
"""
Exception thrown while rendering another exception. Original exception:
${throwable.stackTraceToString()}
Rendering exception:
${ex.stackTraceToString()}
""".trimIndent()
}
}
override fun register(renderer: ThrowableRenderer) {
renderers.add(renderer)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy