Change Summary:
Fix summary
Summary: |
|
---|
Review Request #554 — Created May 7, 2018 and submitted
Information | |
---|---|
pprkut | |
Lunr | |
pprkut:exceptions | |
576 | |
df96749... | |
Reviewers | |
lunr | |
Catch exceptions in a RequestResultHandler class, which can be used by either a FrontController or a Controller class.
The RequestResultHandler sets the proper response codes, which should remove boiler plate code from Controllers.
Unit tests
src/Lunr/Corona/RequestResultHandlerTrait.php (Diff revision 1) |
---|
I'd imagine we'd want to know the exception class here. Maybe make it like
$e::class . ': ' . $e->getMessage();
src/Lunr/Corona/Exceptions/HttpException.php (Diff revision 1) |
---|
to support application specific error, we may create a specific constructor here which would allow an application_error_code parameter
src/Lunr/Corona/FrontController.php (Diff revision 1) |
---|
I didn't understand the review comment about the need to make this a Trait
1st: just to confirm the motivation behind not making that exception handling and result setting directly in the FrontController class
Is it to be flexible and leave the choice of the result handling to the "project" using it?2nd: I am not a big fan of using traits.
They caused too many implementations and testing issues in the past.
I don't see much of their benefits over using a normal RequestResultHandler class there
src/Lunr/Corona/FrontController.php (Diff revision 1) |
---|
This looks weird now: a public function just calling an private function, which is itself only meant for this one.
We may actually now better move that whole function into the Handler itself, no?Not sure why you don't pass the request params as a parameter directly for example too.
Trait -> class
pass params to handle_request
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+1480 -32) |
Add support for application error codes
Description: |
|
|||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
|||||||||||||||||||||
Diff: |
Revision 3 (+1859 -32) |
src/Lunr/Corona/Exceptions/BadRequestException.php (Diff revision 3) |
---|
$code should be renamed to $app_code
as in the HTTPException class
Otherwise this is quite confusingSame in other exception sub classes
src/Lunr/Corona/Exceptions/HttpException.php (Diff revision 3) |
---|
This is not matching the code above in the set_result function where no application code is expected to be represented by NULL
src/Lunr/Corona/FrontController.php (Diff revision 3) |
---|
maybe a better specific naming would be better here
request_result_handler
src/Lunr/Corona/RequestResultHandler.php (Diff revision 3) |
---|
not sure I understand why you put it as "final".
What problems can happen if it would be extended?
Fix parameter name and drop final classifier.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+1857 -32) |