aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util')
-rw-r--r--src/main/kotlin/moe/nea/firmament/util/assertions.kt7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/assertions.kt b/src/main/kotlin/moe/nea/firmament/util/assertions.kt
index 2e2e01a..5505422 100644
--- a/src/main/kotlin/moe/nea/firmament/util/assertions.kt
+++ b/src/main/kotlin/moe/nea/firmament/util/assertions.kt
@@ -9,8 +9,11 @@ package moe.nea.firmament.util
/**
* Less aggressive version of `require(obj != null)`, which fails in devenv but continues at runtime.
*/
-inline fun <T : Any> assertNotNullOr(obj: T?, block: () -> T): T {
- assert(obj != null)
+inline fun <T : Any> assertNotNullOr(obj: T?, message: String? = null, block: () -> T): T {
+ if (message == null)
+ assert(obj != null)
+ else
+ assert(obj != null) { message }
return obj ?: block()
}