https://issues.dlang.org/show_bug.cgi?id=22142

          Issue ID: 22142
           Summary: Improve error reporting for std.curl.net
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: [email protected]
          Reporter: [email protected]

std.net.curl doesn't provide information when something fails. Consider the
following (not terribly obvious) typo:

client.addRequestHeader("Content-Type", "Application/json");

followed by a call to post:

post("https://api.todoist.com/rest/v1/tasks";, cmd, client);

You get only a generic error message:

HTTP request returned status code 400 ()

Compare this with the error message if you do the same thing with command line
curl. The message is:

Empty content

That immediately points you in the right direction. What is the typo? The line
at the beginning should be

client.addRequestHeader("Content-Type", "application/json");

"Status code 400" does not help. "Empty content" does.

--

Reply via email to