[对不起,我使用Kotlin创建了一个CRUD项目,但是我遇到了一个问题enter image description here“主要” java线程中的异常“ java.lang.IllegalStateException:”]我该如何处理上述的Excpetion?
您正在error()
分支中使用error()
函数(可能在else
语句中)。Kotlin中的此函数定义为抛出when
:
IllegalStateException
使用给定的消息引发IllegalStateException。
这是该功能的预期行为。如果您要问这个问题,我想这不是您想要的行为。
抛出异常很可能不是您想要的CLI应用程序中的用户错误。相反,您可以使用fun error(message: Any): Nothing
流将错误消息写入控制台:
stderr