Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[8.x] Add throwWith to the HTTP client response #34558
[8.x] Add throwWith to the HTTP client response #34558
Changes from 1 commit
c131f47
571b36f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the comment should be changed as an exception is not thrown anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
beforeThrowing
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it'd make sense to call
beforeThrowing()->throw()
, which IMO is too bervoseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed on that being to verbose. I was hoping to find something that could express "When throwing, do this thing and then throw" rather than two methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onError
also makes sense to me.throwWith
doesn't make sense to me because it has an indication of which parameters would be given tothrow
(like the Cotnainer'smakeWith
). Though I still preferbeforeThrowing
as it indicates what to do (callback) right before an exception is thrown. I guesswhenThrowing
could also work (like Query Builderwhen()
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree with your objections. As mentioned I didn't know if this was really a great method name.
Maybe there just isn't a nice "all-in-one" option, as
whenThrowing
also makes me wonder if I need to callthrow
or not.Maybe it is just an
onError
callback (as you and others suggested on Twitter).Or maybe I just need to wrap up the more verbose middleware as @sebdesign pointed out in my own app 🤷♂️
I just liked how the error callback and throw was on the other side of the
post
call, as it felt nicer to me being in sequential order, but that is just an opinion that might not be shared.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I prefer the
onError
callback instead of theMiddleware::mapResponse
stuff. It feels nicer and you get to work with theLaravel\Http\Client\Response
instead of the Guzzle response.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we do it as: