aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/ErrorUtil.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/util/ErrorUtil.kt')
-rw-r--r--src/main/kotlin/util/ErrorUtil.kt7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/kotlin/util/ErrorUtil.kt b/src/main/kotlin/util/ErrorUtil.kt
index 2f0acd6..f12bb12 100644
--- a/src/main/kotlin/util/ErrorUtil.kt
+++ b/src/main/kotlin/util/ErrorUtil.kt
@@ -37,6 +37,13 @@ object ErrorUtil {
else Firmament.logger.error(message)
}
+ fun <T> Result<T>.intoCatch(message: String): Catch<T> {
+ return this.map { Catch.succeed(it) }.getOrElse {
+ softError(message, it)
+ Catch.fail(it)
+ }
+ }
+
class Catch<T> private constructor(val value: T?, val exc: Throwable?) {
fun orNull(): T? = value