curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: show the URL in the error message?

From: Daniel Stenberg via curl-users <>
Date: Tue, 17 Nov 2020 23:58:43 +0100 (CET)

On Sun, 15 Nov 2020, Daniel Stenberg via curl-users wrote:

> C. Can we do better?

I took it a bit further, based on an idea Jay brought in the PR[2]: I'm
providing the necessary information as variables for the --write-out option.
This way, a user can design their own error messages!

This example does three transfers in parallel, and the middle one fails. They
all use the same input URL and it uses -s to not show any error message:

$ curl -Z -s localhost -o /tmp/okay localhost -o /tm localhost -o /tmp/okay2
--write-out "%{onerror}curl: (%{exitcode}) %{errormsg} %{url} %{urlnum}\n"

curl: (23) Failure writing output to destination localhost 1

This works thanks to 5 new variables, but the most interesting one is perhaps
'onerror' which makes the rest of the line not show if the exitcode is zero.

With these tools offered, I think maybe I should leave the default error
output as it is.

> [2] =

  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
Received on 2020-11-18