cli: also halt on LastErrorException

This commit is contained in:
Moritz Zwerger 2023-10-08 20:52:09 +02:00
parent 2f3f79dfcd
commit ad4fd8b37f
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.terminal.cli
import com.sun.jna.LastErrorException
import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.kutil.observer.DataObserver.Companion.observe
import de.bixilon.kutil.observer.DataObserver.Companion.observed
@ -84,9 +85,9 @@ object CLI {
line = readLine().trimWhitespaces().replace("\n", "").replace("\r", "")
terminal.flush()
} catch (exception: EndOfFileException) {
Log.log(LogMessageType.GENERAL, LogLevels.VERBOSE) { exception.printStackTrace() }
Log.log(LogMessageType.GENERAL, LogLevels.WARN) { "End of file error in cli thread. Disabling cli." }
break
eol(exception); break
} catch (exception: LastErrorException) {
eol(exception); break
} catch (exception: UserInterruptException) {
ShutdownManager.shutdown(reason = AbstractShutdownReason.DEFAULT)
break
@ -100,6 +101,11 @@ object CLI {
}
}
private fun eol(exception: Throwable) {
Log.log(LogMessageType.GENERAL, LogLevels.VERBOSE) { exception.printStackTrace() }
Log.log(LogMessageType.GENERAL, LogLevels.WARN) { "End of file error in cli thread. Disabling cli." }
}
private fun processLine(line: String) {
try {
ROOT_NODE.execute(line, connection)