This is turning out to be a common problem. :) On 11/30/2014 11:24 AM, Suliman wrote: > I can't understand why I am getting exception on next code: > > void downloadFile() > { > foreach(link; links) > { > try > { > writeln(connect(link)); > } > > catch(Exception msg) > { > writeln(msg);
In capitals to make a lasting effect: DON'T EVER OUTPUT THE EXCEPTION OBJECT!
Otherwise, you will fool yourself and others as if the exception is not being caught.
What is happening is that you are actually catching the exception, printing on screen and exiting cleanly.
There is no point of printing the exception object itself. Instead, print a meaningful message or something else:
} catch(Exception msg) { import std.string; writeln(format("Failed to download '%s'.", link)); } Ali