Skip to content
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

Get error message in non-success cases with WWW-style syntax #8

Open
johnsaigle opened this issue Apr 20, 2018 · 2 comments
Open

Get error message in non-success cases with WWW-style syntax #8

johnsaigle opened this issue Apr 20, 2018 · 2 comments

Comments

@johnsaigle
Copy link

What is the syntax for retrieving error content using WWW syntax (if any)?

Related to #6.

@johnsaigle johnsaigle changed the title Get error message in non-success cases with WWW-style syntax Get error message in non-success cases with WWW-style syntax Apr 20, 2018
@CurtTilmes
Copy link
Owner

CurtTilmes commented Apr 25, 2018

It sets :failonerror by default, which forces it to throw an exception on a non-2xx status code.
You can't really override that with the shortcut syntax. For example, this is get:

LibCurl::HTTP.new(|%opts).GET($url, $filename).perform.content;

You need to stick an extra setopt(:!failonerror) in there before the perform. The GET itself sets :failonerror, so it will override any options that get passed in to the new.

@CurtTilmes
Copy link
Owner

Hmm... Maybe the error checking code could check for the bad status code type of error and stash the content into a special Exception type? Then you could CATCH the exception and still see the actual content. I don't have time to do that now, but perhaps sometime..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants