https://issues.dlang.org/show_bug.cgi?id=18318
Aravinda <hallimanearav...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hallimanearav...@gmail.com --- Comment #2 from Aravinda <hallimanearav...@gmail.com> --- (In reply to Martin Nowak from comment #0) > cat > bug.d << CODE > import std.net.curl; > > void main() > { > // get("dlang.org/non-existent-foobar"); // throws HTTPStatusException > 404 > download("dlang.org/non-existent-foobar", "tmp"); // silently writes 404 > response, with no way to detect the error > } > CODE > > dmd -run bug Below code works with error handling. import std.stdio; import std.net.curl; void main() { auto url = "dlang.org/non-existent-foobar"; auto conn = HTTP(url); download(url, "tmp", conn); auto status = conn.statusLine(); if (status.code == 200){ writeln("Downloaded successfully!"); } else { writefln("Failed to download. Error: %d %s", status.code, status.reason); } } --