-
Notifications
You must be signed in to change notification settings - Fork 39
Move Body, HttpError exceptions, BatchRequest, HttpMethods to utility #59
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
Conversation
* | ||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com> | ||
*/ | ||
final class ServerException extends HttpException |
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.
this means that generic libraries can not catch just client or server exceptions specifically. this makes the distinction in different exceptions pointless. i think we should keep them in here. (and keep the factory logic in HttpException)
good cleanup! can you link the PR that adds the parts that we keep to why exactly do you drop the body implementations? is there a Body
i think the exceptions can not be moved because they must be part of the
but i agree with the other two points, lets have an interface for |
I haven't created the util repository yet. Not until we decide what exactly goes there from this repo. Actualy there is a problem with moving BatchResult to the util repo: BatchException currently creates a new one if none is passed when using the getter. It's a hack to make sure a result is always available. How should we workaround that? Throw an exception if the result is not set? |
We can maybe force a BatchResult into the constructor of the Exception and remove the creation in the getResult ? (The other choice would be to allow null for the getResult method) EDIT : Throw an exception in a exception is a no go for me |
I already thought about that. The problem is that BatchResult is immutable which would cause a lot of confusion. It is injected but the incorrect version is in the exception. |
Didn't see the immutable part, so this is incorrect https://github.com/php-http/adapter/blob/master/src/Util/BatchRequest.php |
Yup, I already noticed that during the movement of classes from the main repo. We can correct it in the util repo once it gets clear what exactly will be in it. |
We can otherwise make BatchException implement this interface, so BatchException is a BatchResult ? |
BatchResult should be immutable, exceptions cannot be made immutable: they cannot be cloned. |
* | ||
* @return Exception | ||
* | ||
* @throws \UnexpectedValueException If request is not found |
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.
If request did not lead to an exception or was not part of the batch request.
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.
Feel free to contribute to the current branch if you can.
@dbu If you have some time, please push commits to this PR. |
pushed some phpdoc cleanup. the only open thing from my side now is #59 (comment) |
I plan to add body generators in the utility package. This also means, that a Body object cannot be passed to the MethodsClient anymore. But the contract is more elegant this way IMO.
I think we can rely on SPL exceptions in this case. The common exception makes sense when you don't care about what really happend, you want to catch all DomainExceptions. But SPL exceptions are used in cases that you called "program errors". If we need an exception for something, which indicates something else then a user error, then we should create our custom exception for that. |
PSR-7 also relies on SPL Exceptions. |
…SPL exceptions where possible
f112f26
to
901d539
Compare
what about the client and server exceptions for 4xx and 5xx ? i remember we discussed back and forth about throwing exceptions versus returning a response with an error status in it. what did we decide in the end? |
We decided to move this functionality to a Plugin. |
move HttpMethodsClient to implementation in utils, rename psr client
07dc75f
to
644ebc5
Compare
Is there anything we need to do before merging this one? |
Move Body, HttpError exceptions, BatchRequest, HttpMethods to utility
yay! |
Adding clients factories for Curl, React and Socket
Moves lots of stuff to the utility package as discussed in #56.
Implementations remaining in this package:
One thing in my mind: while the BatchResult will likely have only one implementation, we should consider moving it to the utility package and having an interface in the contract.
Reasoning:
What do you think guys?