Error handling

enum ExceptionError {
    case isNil, isEmpty
}

func throwWhenNilOrEmpty(_ array: [Int]?) throws {
    if array == nil {
        throw Exception.isNil
    }
    if array!.isEmpty {
        throw Exception.isEmpty
    }
}

do {
    let array = [Int]()
    try throwWhenNilOrEmpty(array)
}
catch Exception.isNil {
    print("array is not specified")
}
catch Exception.isEmpty {
    print("array is empty")
}
catch {}

//or

do {
    try throwWhenNilOrEmpty(nil)
}
catch Exception.isNilException.isEmpty {
    print("please pass an array")
}
catch {}