cURL / Mailing Lists / curl-users / Single Mail

curl-users

error handling in non-html transfer

From: Adam Kellas <adam.kellas_at_gmail.com>
Date: Fri, 22 Mar 2013 08:26:25 -0700

I'm using http as a general-purpose transport protocol to send files to a
server where they're processed and returned to a command line program. This
is basically working, it's just error handling I'm struggling with.

A browser handles errors by rendering an error message in html and not
exiting, but my client needs to behave just like a normal command-line
program. The fact that it hands the job off to a server should be an
implementation detail, but printing error messages to stderr and exiting
with a meaningful status are a problem.

I'm currently using this command on the client side:

% curl -o bar -F inputfile=@foo

When things go well the right data ends up in "bar", but if it fails curl
still exits with 0 leaving something like "500 Internal Server Error" in
it. Is there a way the server can tell curl, or any http client, to print
the body to stderr and exit nonzero? To be clear, I'm hoping to be able to
use the curl program as my client side but if I need to write a custom
client that could be done too. I've thought about adding a custom header
like X-ErrorMessage but don't know if curl could process that.

Thanks,
AK

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-22