In the following code, I want to read a file and return all lines; if there is an input / output error, I want the program to exit with printing the error message to the console. But the program still encounters an unhandled exception. What is the best practice for this? (I think I don’t need it Some/None, because I want the program to exit on error.) Thank you.
let lines =
try
IO.File.ReadAllLines("test.txt")
with
| ex -> failwithf " %s" ex.Message
source
share