+exception registration sugar
This commit is contained in:
parent
39aa031bf0
commit
da1289e3be
@ -34,9 +34,10 @@ open class ExceptionsRegistry {
|
|||||||
* Register an exception with a code with a handler that creates its instance. Note that the
|
* 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.
|
* handler _should not throw anything_ but rather create an instance of the exception.
|
||||||
*/
|
*/
|
||||||
inline fun <reified T : Throwable> register(code: String, noinline block: (message: String?) -> T) {
|
inline fun <reified T : Throwable> register(code: String?=null, noinline block: (message: String?) -> T) {
|
||||||
handlers[code] = block
|
val _code = code ?: T::class.simpleName!!
|
||||||
classCodes[T::class] = code
|
handlers[_code] = block
|
||||||
|
classCodes[T::class] = _code
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user