-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture standard error from curl shell command #16
Comments
Hi Jeff, I think it makes sense to do something similar to clj-http and throw when the status code is somewhere in the 400-500 status code area. Right now the
A PR on this would be welcome! |
Sounds good. I will read up on clj-http’s behavior with exceptions. For example, a timeout will always throw an exception but a 400-500 status code may or may not depending on For my immediate purposes, thanks for bringing up the exit status code. I can use that to capture whether a timeout occurred and then do something about it. |
Hi @borkdude. Here's a first-pass at a PR that captures the standard error and adds a key to the result map if there is an error from the curl shell command (non-zero exit status). I wasn't sure about how it should behave with respect to exceptions. For example, clj-http allows you to opt out of throwing exceptions An exception could be thrown by default if there is a non-zero exit code but that feels like a different concern than throwing an exception for an exceptional http status code. Maybe a different option makes sense like |
|
The above makes sense. I can work on a PR with the above when I get another round of free time. If it throws an exception when the http status code is not "successful" by default and/or throws an exception when the error code is non-zero, that would make the behavior backwards incompatible. Is that ok? |
@jaydeesimon Since this library is fairly new and there is a warning about potential breaking changes in the README, I think that is ok. A note on style: I'd like to avoid keywords with question marks in them. So I think |
Turns out we could throw when streaming, because the status code is known before the stream returns. I've made that change as well. |
Great. Thanks @borkdude ! |
I'm interested in capturing the standard error and doing something with it. For example, when setting a timeout
{:raw-args ["--max-time" "30"]}
. Full example:It looks like the main reason it's empty is because the process's standard error destination is being set to
ProcessBuilder$Redirect/INHERIT
here and therefore not present in the error input stream.The lowest hang fruit thing I can think of is to remove that line so that the default destination is
ProcessBuilder$Redirect/PIPE
but maybe there's a reason it's set toProcessBuilder$Redirect/INHERIT
?Beyond that, there's probably better ways to get at the fact that something went wrong and
curl
returned an error besides manually pulling it from the error input stream (for example, adding it to the result map with a curl error key or throw an exception with details in anExceptionInfo
object).Let me know what you think. I'd be happy to work on a PR.
-Jeff
The text was updated successfully, but these errors were encountered: