I have the following function that finds the Index in an Array
let numbers_array = [| "1"; "2"; "3"|]
let findIndex arr elem = arr |> Array.findIndex ((=) elem)
let s = "123"
findIndex numbers_array (string s.[0]))
However if i try to run
findIndex numbers_array (string s.[10]))
it is out of bounds and throws the following error
System.Collections.Generic.KeyNotFoundException: An index satisfying the predicate was not found in the collection.
How can i make my function so instead of throwing the exception it does something instead like a printf statement?