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.

Printing the URL in the error messages when --fail is passed?

From: Bhavin Gandhi via curl-users <curl-users_at_lists.haxx.se>
Date: Sun, 24 Jul 2022 15:27:41 +0530

Consider following command execution for a link which returns 404.

$ curl --fail https://curl.se/nothing-404
curl: (22) The requested URL returned error: 404

This error is easy to understand, it says that the URL in the command we
just ran returned 404.

Now, let's say we request two URLs:

$ curl --fail https://curl.se/nothing-404 https://curl.se/nothing-404-2
curl: (22) The requested URL returned error: 404
curl: (22) The requested URL returned error: 404

Still possible to somehow figure out which URL returned an error. But if
we have --parallel, then it is not clear which URL actually caused an
error.

I often use the --config option to pass a configuration file which
downloads multiple files from a location. In this case as well, we will
have the same issue.

One solution is to use the --verbose option, but it gives a lot more
information than just the URL. So, one has to dig into the long output,
filter it out to know which URLs failed.
Is there any other command line option which can help here? I was not
able to find anything relevant in the manual as well as on the Internet
after a few searches.

A possible way is to print the URL in the error message itself. If that
will break compatibility for some users, then it can be behind a command
line option like --show-error-url. Will this approach have any other
problems?

-- 
Bhavin Gandhi (bhavin192) | https://geeksocket.in
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2022-07-24