[Issue 22142] New: Improve error reporting for std.curl.net

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 25 15:37:27 UTC 2021


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: nobody at puremagic.com
          Reporter: bachmeil at yahoo.com

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.

--


More information about the Digitalmars-d-bugs mailing list