Improve error message when input cannot be read.

This commit is contained in:
Sven Weidauer 2024-12-03 19:01:43 +01:00
parent cc8abea2c4
commit b37bdc8b3e

View file

@ -1,8 +1,8 @@
fun readInput(name: String) = bufferedReader(name) fun readInput(name: String) = bufferedReader(name)
?.lineSequence() ?.lineSequence()
?: error("Cannot read input") ?: error("Cannot read input $name")
fun readInputString(name: String): String = bufferedReader(name)?.readText() ?: error("Cannot read input") fun readInputString(name: String): String = bufferedReader(name)?.readText() ?: error("Cannot read input $name")
private fun bufferedReader(name: String) = object {}.javaClass.getResourceAsStream(name) private fun bufferedReader(name: String) = object {}.javaClass.getResourceAsStream(name)
?.bufferedReader() ?.bufferedReader()