jsMain.com.squareup.sqldelight.db.Closeable.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of runtime Show documentation
Show all versions of runtime Show documentation
Multiplatform runtime library to support generated code
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