this code is used as an example, and to show the exception.
open System.Net
let baseUrl = "http://fsharp.org/"
let someWords = ["learn"; "working"; "teaching"; "testimonials"]
let downloadFile (url : string) (filePath : string) =
use wc = new System.Net.WebClient()
wc.DownloadFile(url, filePath)
for words in someWords do
let joinedUrl =
baseUrl
+ words.ToString()
System.Console.WriteLine(joinedUrl)
downloadFile joinedUrl (@"C:\temp\file" + words + ".txt")
The "http://fsharp.org/working" throws a 'System.Net.WebException' because it doesn't exist and the for loop
stops.
I want that the loop continues with the next string, in this case "teaching".
I have tried to handle the exception with try...with
and also adding reraise()
but I haven't solved the problem yet.