+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
|
||||
* 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) {
|
||||
handlers[code] = block
|
||||
classCodes[T::class] = code
|
||||
inline fun <reified T : Throwable> register(code: String?=null, noinline block: (message: String?) -> T) {
|
||||
val _code = code ?: T::class.simpleName!!
|
||||
handlers[_code] = block
|
||||
classCodes[T::class] = _code
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user