On Sunday, 30 November 2014 at 19:24:39 UTC, 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);
                        }
                }
        }

Change this here:

catch (Exception msg)
{
    writeln(msg);
}

to:

catch (Exception msg)
{
    writeln(msg.msg);
}

The problem is that you are catching the exception and then printing it out, which prints a string representation of the exception. This string representation includes the exception's message and its stack trace. What you probably want is to print out its .msg member, which is the error message.

Reply via email to