Add the ability to configure and match exceptions with an HTTP status code#797
Merged
dunglas merged 1 commit intoOct 14, 2016
Conversation
meyerbaptiste
force-pushed
the
add_exception_to_status_configuration
branch
2 times, most recently
from
October 11, 2016 13:46
7df3cb2 to
c5648d8
Compare
theofidry
suggested changes
Oct 11, 2016
theofidry
left a comment
Contributor
There was a problem hiding this comment.
I really like the idea 👍
| private $exceptionToStatus; | ||
|
|
||
| public function __construct(SerializerInterface $serializer, array $errorFormats, $exceptionToStatus = []) | ||
| public function __construct(SerializerInterface $serializer, array $errorFormats, array $exceptionToStatus = []) |
Contributor
There was a problem hiding this comment.
I would add a phpdoc with examples of the possible values for $errorFormats and $exceptionToStatus, it is not clear from just looking at the constructor what those values can be although the tests gives some hints
| /** | ||
| * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException | ||
| * @expectedExceptionMessageRegExp /The HTTP status code ".+" is not valid\./ | ||
| * @dataProvider invalidHttpStatusCodeProvider |
Contributor
There was a problem hiding this comment.
I would declare the @dataProvider first, to keep the lexicographical order
soyuka
requested changes
Oct 12, 2016
| enable_nelmio_api_doc: true | ||
| exception_to_status: | ||
| Symfony\Component\Serializer\Exception\ExceptionInterface: 400 | ||
| ApiPlatform\Core\Exception\InvalidArgumentException: 'HTTP_BAD_REQUEST' |
Member
There was a problem hiding this comment.
+1 really like the improvement, this however should be documented!
Member
Author
There was a problem hiding this comment.
I will open a PR for the doc.
dunglas
approved these changes
Oct 12, 2016
meyerbaptiste
force-pushed
the
add_exception_to_status_configuration
branch
2 times, most recently
from
October 13, 2016 15:58
e22295b to
58b6a24
Compare
meyerbaptiste
force-pushed
the
add_exception_to_status_configuration
branch
from
October 13, 2016 15:59
58b6a24 to
e9c1863
Compare
theofidry
approved these changes
Oct 13, 2016
teohhanhui
approved these changes
Oct 14, 2016
Member
|
Thanks @meyerbaptiste |
soyuka
pushed a commit
to soyuka/doc
that referenced
this pull request
Oct 14, 2016
soyuka
pushed a commit
to soyuka/doc
that referenced
this pull request
Oct 14, 2016
magarzon
pushed a commit
to magarzon/core
that referenced
this pull request
Feb 12, 2017
…to_status_configuration Add the ability to configure and match exceptions with an HTTP status code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds the ability to configure and match exceptions with an HTTP status code and to override default exceptions (i.e.,
Symfony\Component\Serializer\Exception\UnexpectedValueExceptionandSymfony\Component\Serializer\Exception\ExceptionInterfaceto 400 HTTP error).Example of configuration: