Exception handling

class IsNullExceptionException()
class IsEmptyExceptionException()

fun throwWhenNullOrEmpty(list: Array<Int>?) {
    if (list == null) {
        throw IsNullException()
    }
    if (!list.any()) {
        throw IsEmptyException()
    }
}

try {
    throwWhenNullOrEmpty(null)
}
catch(e: Exception) {
    println("Error happened")
}