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: Printing the URL in the error messages when --fail is passed?

From: Timothe Litt <litt_at_acm.org>
Date: Sun, 24 Jul 2022 09:01:36 -0400

I agree that this is bad behavior.

Seems to me that the best solution is to report the URL if a command
includes more that one request, but leave the generic message
otherwise.  This should minimize the possibility of breaking anyone who
counts on the message (though scripts really shouldn't, there's probably
someone with an expect script.)

e.g.

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

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

It wouldn't be terrible to report the URL in every case, just marginally
less compatible.

I don't think it's worth having yet another command option, which would
require documentation and tests.


Timothe Litt
ACM Distinguished Engineer
--------------------------
This communication may not represent the ACM or my employer's views,
if any, on the matters discussed.

On 24-Jul-22 05:57, Bhavin Gandhi via curl-users wrote:
> Consider following command execution for a link which returns 404.
>
> $ curl --failhttps://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 --failhttps://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?
>

-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2022-07-24