Skip to content

Commit 0927e20

Browse files
Improve JsonWrapper utility
1 parent 7a509b8 commit 0927e20

File tree

1 file changed

+2
-1
lines changed
  • heartbeat_monitor/src/jsMain/kotlin/heartbeatmonitor/util

1 file changed

+2
-1
lines changed

heartbeat_monitor/src/jsMain/kotlin/heartbeatmonitor/util/JsonWrapper.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inline fun <T> wrap(block: () -> T): T {
1212
return try {
1313
block()
1414
} catch (e: dynamic) {
15-
throw IllegalArgumentException("${e.message} at ${context.path}", e)
15+
throw IllegalArgumentException("${e.message ?: "$e"} at ${context.path}", e)
1616
}
1717
}
1818

@@ -128,6 +128,7 @@ class JsonObjectItemAccessor(private val parent: JsonProvider, private val key:
128128
override fun asJsonOrCreate(): JsonObject {
129129
val parentValue = parent.asJsonOrCreate()
130130
return JsonUtils.asJsonObjectOrNull(parentValue[key]) ?: run {
131+
if (key in parentValue) throw IllegalStateException("Not a Json at $path")
131132
val value = jsonObject()
132133
parentValue[key] = value
133134
value

0 commit comments

Comments
 (0)