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: Bhavin Gandhi via curl-users <curl-users_at_lists.haxx.se>
Date: Sun, 24 Jul 2022 20:29:45 +0530

On Sun, 24 Jul 2022 at 19:28, Daniel Stenberg <daniel_at_haxx.se> wrote:
> > 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.
>
> -w is your friend.
>
> I blogged about it to some length a while ago:
>
> https://daniel.haxx.se/blog/2021/01/27/curl-your-own-error-message/
>

Aha! I was aware of -w, but this didn't occur to me that I can use it
for error as well. I should have read the manual carefully, especially
the -w section.
This solves the above issue, and I don't think the default behavior needs to
be changed. Thank you!

I came up with the following one for my use case:

$ curl --write-out '%{onerror}%{urlnum}: %{url}: %{errormsg}\n' \
    --parallel --fail --silent \
    https://curl.se/nothing-404 https://curl.se/nothing-404-2

1: https://curl.se/nothing-404-2: The requested URL returned error: 404
0: https://curl.se/nothing-404: The requested URL returned error: 404

Thank you Timothe for sharing your thoughts about it :)

-- 
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