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

commonMain.LoggingInit.kt Maven / Gradle / Ivy

package kt.mobius

import kt.mobius.internal_util.Throwables

class LoggingInit internal constructor(
    private val actualInit: Init,
    private val logger: MobiusLoop.Logger
) : Init {

    override fun init(model: M): First {
        logger.beforeInit(model)
        val result = safeInvokeInit(model)
        logger.afterInit(model, result)
        return result
    }

    private fun safeInvokeInit(model: M): First {
        try {
            return actualInit.init(model)
        } catch (e: Exception) {
            logger.exceptionDuringInit(model, e)
            throw Throwables.propagate(e)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy