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

br.com.guiabolso.tracing.utils.ExceptionUtils.kt Maven / Gradle / Ivy

The newest version!
package br.com.guiabolso.tracing.utils

import java.io.PrintWriter
import java.io.StringWriter

object ExceptionUtils {

    @JvmStatic
    fun getStackTrace(throwable: Throwable): String {
        val sw = StringWriter()
        val pw = PrintWriter(sw, true)
        throwable.printStackTrace(pw)
        return sw.buffer.toString()
    }

    @Suppress("SwallowedException")
    fun  doNotFail(func: () -> T): T? {
        return try {
            func()
        } catch (t: Throwable) {
            null
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy