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
Logger middleware just crashes #317
Comments
This is expected. None of the middleware can work without HTTP requests being made, i.e. without an adapter. Faraday.new(url: "http://google.com") do |conn|
conn.response :logger
conn.adapter Faraday.default_adapter
end |
@mislav while this is the expected behavior, the resulting error message could be more useful. |
I agree with @sethvargo, the message could be better. In my case, I went from no parameters to |
I also ran into this problem. I'd say that the expected behaviour is that Faraday uses the default adapter if one isn't specified. If you'd rather not do this, an 'adaptor not specified' exception would save a lot of head scratching. |
@mislav I was about to say exactly what @bluefuton just said. I mean it is called the "default_adapter", which suggests that it's the default one. |
Oh, I was just bitten by the same thing. Cryptic error message for what is likely a common mistake. (I removed the adapter specification because I mistakenly assumed it needn't be explicit.) @mislav Would you accept a pull request to change the error to something like "No adapter specified"? Or (but you seem to not want this) to assume the "default adapter" if nothing is explicitly specified? |
Oh, hey @pengwynn, noticed you're part of this organization as well. Since Mislav didn't reply above, any thoughts on this? Don't mean to step on anyone's toes, though – if Mislav makes these calls I don't want to bypass him :) |
The message should be better. Although, as I said, none of the middleware will actually work without an adapter. So, improving the error message specifically for this middleware leaves other cryptic failures in other middleware. The proper solution should be that Faraday aborts early when a Connection object doesn't include an adapter in the stack. Please subscribe to one of #47, #121, #170 |
@mislav Aha, thank you for clarifying! I think I'll try to make a pull request just to improve the error message from logger – it seems like it could be a fairly simple change that would improve on a common gotcha. Hope that's OK. I might look into the proper fix also, but it seems more challenging, so I might not have the time or skill to achieve that. |
The current error message has confused people: lostisland#317 As discussed there, there are better longer-term solutions, but no one has implemented those yet.
When adding middleware to the faraday connection we need to be explicit about which adapter we'll use, otherwise no HTTP requests are actually made. Sadly, Faraday doesn't raise an exception if the adapter is missing and you end up debugging cryptic error messages raised from the middleware :pandaface: For more information see: lostisland/faraday#317
When adding middleware to the faraday connection we need to be explicit about which adapter we'll use, otherwise no HTTP requests are actually made. Sadly, Faraday doesn't raise an exception if the adapter is missing and you end up debugging cryptic error messages raised from the middleware 🐼 For more information see: lostisland/faraday#317
When adding middleware to the faraday connection we need to be explicit about which adapter we'll use, otherwise no HTTP requests are actually made. Sadly, Faraday doesn't raise an exception if the adapter is missing and you end up debugging cryptic error messages raised from the middleware 🐼 For more information see: lostisland/faraday#317
This simple program crashes because when logger is called there no headers and body yet.
The text was updated successfully, but these errors were encountered: