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