Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Add response status code for the Whoops error handler #476

Merged
merged 3 commits into from
Mar 28, 2017
Merged

Add response status code for the Whoops error handler #476

merged 3 commits into from
Mar 28, 2017

Conversation

geerteltink
Copy link
Member

fixes #475

Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

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

Looks good, in general. I think we need an additional test for when $e has an exception code that falls elsewhere in the 400-599 range, to validate that the response status is set accordingly.


$this->response->withStatus(StatusCode::STATUS_INTERNAL_SERVER_ERROR)->will([$this->response, 'reveal']);
$this->response->getBody()->will([$this->stream, 'reveal']);
$this->response->getStatusCode()->willReturn(StatusCode::STATUS_MOVED_PERMANENTLY);
Copy link
Member

Choose a reason for hiding this comment

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

wait... shouldn't this be StatusCode::STATUS_INTERNAL_SERVER_ERROR here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's deliberately an error code below 400 to make sure Utils::getStatusCode does its job and returns the default 500 code. However I don't know if it should be tested here and just rely on Stratigility tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Uhm, it doesn't make sense since the default error code is 0. So it's already converted and tested in the previous tests.

$this->response->withStatus(StatusCode::STATUS_INTERNAL_SERVER_ERROR)->will([$this->response, 'reveal']);
$this->response->getStatusCode()->willReturn(StatusCode::STATUS_INTERNAL_SERVER_ERROR);
$this->response->withStatus(StatusCode::STATUS_IM_A_TEAPOT)->will([$this->response, 'reveal']);
$this->response->getStatusCode()->willReturn(StatusCode::STATUS_IM_A_TEAPOT);
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand this change. $error here is a simple RuntimeException, so I'd expect an internal server error. Or are you redefining the $error somehow?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks good, in general. I think we need an additional test for when $e has an exception code that falls elsewhere in the 400-599 range, to validate that the response status is set accordingly.

I might have misunderstood that... or you wanted to see changes to the default RunTimeException error code.

Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks, @xtreamwayz !

@weierophinney weierophinney added this to the 2.0.3 milestone Mar 28, 2017
@weierophinney weierophinney merged commit b061437 into zendframework:master Mar 28, 2017
weierophinney added a commit that referenced this pull request Mar 28, 2017
Add response status code for the Whoops error handler
weierophinney added a commit that referenced this pull request Mar 28, 2017
weierophinney added a commit that referenced this pull request Mar 28, 2017
weierophinney added a commit that referenced this pull request Mar 28, 2017
@geerteltink geerteltink deleted the hotfix/475 branch March 28, 2017 16:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Whoops json error response uses status code 200
2 participants