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

jsMain.com.squareup.sqldelight.db.Closeable.kt Maven / Gradle / Ivy

The newest version!
package com.squareup.sqldelight.db

actual interface Closeable {
  actual fun close()
}

actual inline fun  T.use(body: (T) -> R): R {
  var exception: Throwable? = null
  try {
    return body(this)
  } catch (e: Throwable) {
    exception = e
    throw e
  } finally {
    when {
      this == null -> {}
      exception == null -> close()
      else ->
        try {
          close()
        } catch (closeException: Throwable) {
          // Nothing to do...
        }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy