Skip to content
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

Whoops: Allow Exceptions to send custom HTTP code #3237

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

lukasbestle
Copy link
Member

@lukasbestle lukasbestle commented Apr 9, 2021

Describe the PR

Whoops overrides any sent HTTP code with its own HTTP 500 unless disabled. This meant that any JSON error response would have HTTP 500 even if the Exception has defined a different code.

It's still the same with the HTML output, but here it's more difficult to set a custom code as we don't have dynamic access to the handled Exception.

Ready?

  • Added unit tests for fixed bug/feature Automated Whoops tests are not possible
  • Added in-code documentation (if needed)
  • CI passes (runs automatically when the PR is created or run composer ci locally)
    Running locally requires PHPUnit, PHP-CS-Fixer, Psalm, PHPCPD and PHPMD.

Whoops overrides any sent HTTP code with its own `HTTP 500` unless disabled. This meant that any JSON error response would have `HTTP 500` even if the `Exception` has defined a different code.
@lukasbestle lukasbestle added this to the 3.5.4 milestone Apr 9, 2021
@lukasbestle lukasbestle requested a review from a team April 9, 2021 19:39
@lukasbestle lukasbestle self-assigned this Apr 9, 2021
Copy link
Member

@bastianallgeier bastianallgeier left a comment

Choose a reason for hiding this comment

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

Will our error response code be even sent before this?

Copy link
Member

@bastianallgeier bastianallgeier left a comment

Choose a reason for hiding this comment

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

Sorry, that was a stupid question. Our Response class is taking care of it in the handler. Should have checked out the entire code of the file.

@bastianallgeier bastianallgeier merged commit 787fa45 into develop Apr 27, 2021
@bastianallgeier bastianallgeier deleted the fix/whoops-json-error-code branch April 27, 2021 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants