Skip to content

Conversation

Ayesh
Copy link
Member

@Ayesh Ayesh commented Feb 26, 2024

Currently, request_parse_body function throws an InvalidArgumentException exception if the request Content-Type header is invalid or of an unknown type such as application/json.

To make this consistent with other exception conditions, this changes the exception type from InvalidArgumentException to RequestParseBodyException.

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense. It would be actually also good to not have the exception in zend but rather some exception defined in standard ext as it is standar specific.

Ping for @iluuu1994 in case there is some good reason to use InvalidArgumentException that I'm missing.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me.

I would rather not have SPL exceptions used anywhere outside of SPL, as a lot of them can be converted to user ValueErrors.

@iluuu1994
Copy link
Member

According to the RFC, it should be the other way around, both should be InvalidArgumentExceptions. Admittedly, given that the content-type is no longer an argument, the exception doesn't make too much sense anymore. I'm ok with switching both to RequestParseBodyException, but maybe send a quick e-mail to the list (if it works, that is 😋).

@iluuu1994
Copy link
Member

I think it makes sense. It would be actually also good to not have the exception in zend but rather some exception defined in standard ext as it is standar specific.

The reason it's there is because it's not just referenced from ext but also main. We generally don't do that from Zend, but I see there's already references to ext from main. TBH the separation of ext/standard, main and Zend is largely arbitrary.

…er exception to `RequestParseBodyException`

Currently, `request_parse_body` function throws an `InvalidArgumentException` exception if the request
`Content-Type` header is invalid or of an unknown type such as `application/json`.

To make this consistent with other exception conditions, this changes the exception type from
`InvalidArgumentException` to `RequestParseBodyException`.
@Ayesh Ayesh force-pushed the rfc1867-exception-consistency branch from 53ac278 to 48febb7 Compare March 6, 2024 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants