curl: catching exception on connect.

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 30 11:24:38 PST 2014


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);
			}
		}
	}
	
Exception text:

std.net.curl.CurlException at C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl
.d(779): HTTP request returned status code 400
----------------
0x0040A536 in pure @safe bool
std.exception.enforceEx!(std.net.curl.CurlExceptio
n).enforceEx!(bool).enforceEx(bool, lazy immutable(char)[],
immutable(char)[], u
int) at
C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\exception.d(529)
0x004073EC in char[]
std.net.curl._basicHTTP!(char)._basicHTTP(const(char)[], co
nst(void)[], std.net.curl.HTTP) at
C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\
net\curl.d(784)
0x0040720C in char[]
std.net.curl.connect!(char).connect(const(char)[], std.net.
curl.HTTP) at
C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl.d(694)
0x00402386 in void app.simpleDownload.downloadFile()
0x0040206D in _Dmain at D:\code\imgDownload\source\app.d(20)
0x00437C08 in void rt.dmain2._d_run_main(int, char**, extern (C)
int function(ch
ar[][])*).runAll().void __lambda1()
0x00437BDB in void rt.dmain2._d_run_main(int, char**, extern (C)
int function(ch
ar[][])*).runAll()
0x00437AF4 in _d_run_main
0x00432FEC in main
0x0047529D in mainCRTStartup
0x7729336A in BaseThreadInitThunk
0x77A59F72 in RtlInitializeExceptionChain
0x77A59F45 in RtlInitializeExceptionChain
std.net.curl.CurlException at C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl
.d(779): HTTP request returned status code 400

By the code App should simply write the server response like 400
or 200. But it's simply crash.

It's look like I do not right understand exception level and way
of use them. Could anybody help me?


More information about the Digitalmars-d-learn mailing list