mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 11:24:35 -05:00
* Update to exposed-migrations v3.5.0 * Update to kotlin-logging v7.0.0 * Update to exposed v0.46.0 * Update to exposed v0.47.0 * Update to exposed v0.55.0 * Update to exposed v0.56.0 * Update to exposed v0.57.0
28 lines
757 B
Kotlin
28 lines
757 B
Kotlin
package suwayomi.tachidesk.graphql
|
|
|
|
import com.expediagroup.graphql.server.extensions.toGraphQLError
|
|
import graphql.execution.DataFetcherResult
|
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
|
|
|
val logger = KotlinLogging.logger { }
|
|
|
|
inline fun <T> asDataFetcherResult(block: () -> T): DataFetcherResult<T?> {
|
|
val result =
|
|
runCatching {
|
|
block()
|
|
}
|
|
|
|
if (result.isFailure) {
|
|
logger.error(result.exceptionOrNull()) { "asDataFetcherResult: failed due to" }
|
|
return DataFetcherResult
|
|
.newResult<T?>()
|
|
.error(result.exceptionOrNull()?.toGraphQLError())
|
|
.build()
|
|
}
|
|
|
|
return DataFetcherResult
|
|
.newResult<T?>()
|
|
.data(result.getOrNull())
|
|
.build()
|
|
}
|