KT.THROWING_EXCEPTION_IN_MAIN

Exception thrown in a main method

This rule reports all exceptions that are thrown in a main method. An exception should only be thrown if it can be handled by a higher function.

Noncompliant Code

Copy
fun main(args: Array<String>) {
    // ...
    throw IOException() // exception should not be thrown here
}

The content on this page is adapted from the Detekt Docs. Copyright ©2022 The Detekt Team. All rights reserved. https://detekt.dev/comments.html