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

HttpExceptions do not set HTTP status code and ErrorHandler does not work as expected in testing enviroment #2516

Closed
cebe opened this issue Feb 22, 2014 · 7 comments · Fixed by #2916
Assignees
Labels
Milestone

Comments

@cebe
Copy link
Member

cebe commented Feb 22, 2014

I am currently testing an API system and noticed that HTTP exceptions display the error page just fine but always with status code 200 instead of the exception code.
Also we have several checks for if(YII_ENV_TEST) which make it hard to test error cases for example in an API where I want to test the json output but actually get only the message of the exception because in YII_ENV_TEST works different.

ErrorHandling code is quite overcomplicated right now and could use a refactoring...

@cebe cebe added this to the 2.0 Beta milestone Feb 22, 2014
@cebe cebe self-assigned this Feb 22, 2014
@Ragazzo
Copy link
Contributor

Ragazzo commented Feb 22, 2014

i think we also should add exception http class for 500 server error, currently we dont have it.

@cebe
Copy link
Member Author

cebe commented Feb 22, 2014

there is no need as any non-HTTP exception should result in code 500.

@Ragazzo
Copy link
Contributor

Ragazzo commented Feb 22, 2014

hm, but we dont have it, why if we have 400 we dont have 500? it exists and should be used in core in error handler if needed, and this row will be eliminated.

@cebe
Copy link
Member Author

cebe commented Feb 22, 2014

errorhandler should not throw an exception as it is the place where header should be set. Any other use case?

@Ragazzo
Copy link
Contributor

Ragazzo commented Feb 22, 2014

nope, but i think we should be consistent.

@cebe
Copy link
Member Author

cebe commented Mar 3, 2014

Also ErrorException should extend from the PHP base class for error exceptions according to what is beeing discussed here: php-fig/fig-standards#262

@cebe
Copy link
Member Author

cebe commented Mar 16, 2014

#303 (comment)
@qiangxue @cebe can we make the default behavior for REST exceptions when YII_DEBUG is true print a stack trace?

relates to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants