All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryException.kt Maven / Gradle / Ivy

Go to download

Implementation of REPL compiler and preprocessor for Jupyter dialect of Kotlin (IDE-compatible)

The newest version!
package org.jetbrains.kotlinx.jupyter.exceptions

class ReplLibraryException(
    libraryName: String? = null,
    val part: LibraryProblemPart,
    cause: Throwable? = null,
) : ReplException(
        "The problem is found in ${libraryName?.let { "library $it" } ?: "one of the loaded libraries"}: check library ${part.message}",
        cause,
    )

enum class LibraryProblemPart(val message: String) {
    PREBUILT("imports, dependencies and repositories"),
    INIT("init codes"),
    RESOURCES("resources definitions"),
    RENDERERS("renderers"),
    TEXT_RENDERERS("text renderers"),
    THROWABLE_RENDERERS("throwable renderers"),
    CONVERTERS("converters (fields callbacks)"),
    CLASS_ANNOTATIONS("class annotations callbacks"),
    FILE_ANNOTATIONS("file annotations callbacks"),
    BEFORE_CELL_CALLBACKS("initCell codes (before-cell-execution callbacks)"),
    AFTER_CELL_CALLBACKS("after-cell-execution callbacks"),
    INTERNAL_VARIABLES_MARKERS("internal variables markers"),
    SHUTDOWN("shutdown callbacks/codes"),
    INTERRUPTION_CALLBACKS("interruption callbacks"),
    COLOR_SCHEME_CHANGE_CALLBACKS("color scheme change callbacks"),
    CODE_PREPROCESSORS("code preprocessors"),
}

fun  rethrowAsLibraryException(
    part: LibraryProblemPart,
    action: () -> T,
): T {
    return try {
        action()
    } catch (e: Throwable) {
        throw ReplLibraryException(part = part, cause = e)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy