class IsNullException: Exception()
class IsEmptyException: Exception()
fun throwWhenNullOrEmpty(list: Array<Int>?) {
if (list == null) {
throw IsNullException()
}
if (!list.any()) {
throw IsEmptyException()
}
}
try {
val list = arrayOf<Int>()
throwWhenNullOrEmpty(list)
}
catch(e: IsNullException) {
println("list is not specified")
}
catch(e: IsEmptyException) {
println("list is empty")
}