curl: catching exception on connect.

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 30 23:28:21 PST 2014


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.


More information about the Digitalmars-d-learn mailing list