Throwing instead of anonymous print

This commit is contained in:
Brage Skjønborg 2026-01-21 19:09:58 +01:00
parent 40e9c9d265
commit 8ec9711e58

View File

@ -24,8 +24,7 @@ object ZDS {
fun Event.toPersisted(id: Long, persistedAt: LocalDateTime = LocalDateTime.now()): PersistedEvent? {
val payloadJson = gson.toJson(this)
val eventName = this::class.simpleName ?: run {
println("Missing class name for event: $this")
return null
throw IllegalStateException("Missing class name for event: $this")
}
return PersistedEvent(
id = id,
@ -43,8 +42,7 @@ object ZDS {
fun PersistedEvent.toEvent(): Event? {
val clazz = EventTypeRegistry.resolve(event)
?: run {
println("Missing class name for event: $this")
return null
throw IllegalStateException("Missing class name for event: $this")
}
return gson.fromJson(data, clazz)
}
@ -52,8 +50,7 @@ object ZDS {
fun Task.toPersisted(id: Long, status: TaskStatus = TaskStatus.Pending, persistedAt: LocalDateTime = LocalDateTime.now()): PersistedTask? {
val payloadJson = gson.toJson(this)
val taskName = this::class.simpleName ?: run {
println("Missing class name for task: $this")
return null
throw IllegalStateException("Missing class name for task: $this")
}
return PersistedTask(
id = id,