Avoid throwing exceptions within the 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.
Since main
is usually at the top of the call stack, there is nothing else above main
to catch any exceptions.
Any exceptions that are explicitly thrown should always be caught elsewhere.
fun main(args: Array<String>) {
// ...
throw IOException() // exception should not be thrown here
}
Don't throw exceptions in the main
method.