I have some suspending functions that can throw ex...
# coroutines
c
I have some suspending functions that can throw exception. If I mark them with
@Throws
, callers of these functions don't get "warned" in the IDE about this. I remember many years ago that I saw something like this at IntelliJ/Android Studio with java code? Does this exist for Kotlin? Is there a recommended way to deal with throwing / non-throwing suspending functions? (I am using Android Studio)
g
I think it's not unique for suspend functions, I don't think that Kotlin warns about checked exceptions at all
c
hmm, it's not checked exceptions I guess, I only added
@Throws
and did not specify exception classes
g
It is checked exception. @Throws add exception to method signature on JVM
c
Ah okay I see :D so there's no way to have ide integration for anything exception related?
g
I don't know any generic mechanics for it on Kotlin compiler or Idea
In general it's a big topic about error handling in Kotlin, but checked exceptions are not really well supported in any case, concidering that they intentionally removed from the language Recommended approach is avoid exceptions when possible, catch on higher level of your code, but not sure that there is any official guide
👍 1
a
Kotlin exception handling is a popular rant topic. My favorite: https://www.reddit.com/r/Kotlin/comments/u9am18/why_no_one_recommends_the_use_of_the_standard/ I've stumbled upon https://github.com/thirdegg/lint-rules recently that adds checked exceptions as lint warnings, but haven't tried. Maybe you can give it a whirl? I'd be stoked to have a better checked exceptions story, let me know if you find a solution you like!