class IsNullException: Exception()
class IsEmptyException: Exception()
fun throwWhenNullOrEmpty(list: Array<Int>?) {
if (list == null) {
throw IsNullException()
}
if (!list.any()) {
throw IsEmptyException()
}
}
try {
throwWhenNullOrEmpty(null)
}
catch(e: Exception) {
println("Error happened")
}