Mercurial > cgi-bin > hgweb.cgi > PassMan
diff src/main/kotlin/name/blackcap/passman/Console.kt @ 21:ea65ab890f66
More work to support interactive feature.
author | David Barts <n5jrn@me.com> |
---|---|
date | Tue, 02 Jul 2024 11:27:39 -0700 |
parents | a6cfdffcaa94 |
children |
line wrap: on
line diff
--- a/src/main/kotlin/name/blackcap/passman/Console.kt Sun Jun 30 22:28:52 2024 -0700 +++ b/src/main/kotlin/name/blackcap/passman/Console.kt Tue Jul 02 11:27:39 2024 -0700 @@ -33,7 +33,7 @@ private fun <T> must(getter: () -> T, checker: (T) -> Boolean): T { while (true) { - var got = getter() + val got = getter() if (checker(got)) { return got } @@ -42,9 +42,8 @@ } private fun <T> doConsoleIo(getter: () -> T?, message: String): T { - val ret = getter() - if (ret == null) { - die(message) - } - return ret!! + val ret = getter() ?: throw ConsoleException(message) + return ret } + +class ConsoleException(message: String, cause: Throwable? = null) : MessagedException(message, cause)