diff --git a/src/commonMain/kotlin/net.sergeych.parsec3/ExceptionsRegistry.kt b/src/commonMain/kotlin/net.sergeych.parsec3/ExceptionsRegistry.kt index 037ab62..7fe7932 100644 --- a/src/commonMain/kotlin/net.sergeych.parsec3/ExceptionsRegistry.kt +++ b/src/commonMain/kotlin/net.sergeych.parsec3/ExceptionsRegistry.kt @@ -34,9 +34,10 @@ open class ExceptionsRegistry { * Register an exception with a code with a handler that creates its instance. Note that the * handler _should not throw anything_ but rather create an instance of the exception. */ - inline fun register(code: String, noinline block: (message: String?) -> T) { - handlers[code] = block - classCodes[T::class] = code + inline fun register(code: String?=null, noinline block: (message: String?) -> T) { + val _code = code ?: T::class.simpleName!! + handlers[_code] = block + classCodes[T::class] = _code } /**