Could develop a plugin to prompt checked exception in Kotlin?


#1

Kotlin language, not like java, make me must try catch the checked exception. it is cool, but I need a plugin to prompt the function could throws checked exception, so I can decide whether to handle.for example.Highlight the called function that could throws checked exception… It is difficult to develop this plugin. so,could someone help developing this plugin .


#2

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-throws/index.html is what you are looking for I think.


#3

image
Kotlin code could not prompt information about checked exception,or I read the implementation of ‘readFile’.
when I read the implementation, I know the function can throws checked exception and will pay attention to using this function.
image
like java highlight the called function,but not must try catch ,just as a prompt, and I can decide whether to handle .


#4

I don’t think a plugin is the right way to solve this. IMO this should be a intention for IntelliJ idea as part of the kotlin plugin. I would suggest you create an issue here: https://youtrack.jetbrains.com/issues/KT#newissue

I’m not exactly sure, I don’t think it should be to hard and this would definitely be added faster if you add the intention yourself. Maybe take a look at https://github.com/JetBrains/kotlin/#contributing


#5

I am deeply grateful for your help


#6

See point 14


#7

It is very kind of you! Thank you for your answer.