异常处理

class IsNilException < StandardError
end

class IsEmptyException < StandardError
end

def throw_when_null_or_empty(data)   
    raise IsNilException if data == nil

    raise IsEmptyException if data.size == 0
end

begin
    throw_when_null_or_empty([])
rescue IsNilException
    puts "list is not specified"
rescue IsEmptyException
    puts "list is empty"
end