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

Forgotten error.status_code and error.headers #365

Closed
decaz opened this issue Feb 1, 2019 · 7 comments

Comments

@decaz
Copy link

commented Feb 1, 2019

Despite #327 and #336 there are still error.status_code and error.headers at several places within the code base.

@sloria

This comment has been minimized.

Copy link
Member

commented Feb 2, 2019

@decaz Where do you see usages of ValidationError.status_code?

@decaz

This comment has been minimized.

Copy link
Author

commented Feb 2, 2019

$ grep -r "error\.status_code" .
./webargs/falconparser.py:            raise LookupError("Status code {0} not supported".format(error.status_code))
./webargs/aiohttpparser.py:            raise LookupError("No exception for {0}".format(error.status_code))
./tests/test_tornadoparser.py:        assert error.status_code == 400
./tests/test_core.py:    assert error.status_code == 418
$ grep -r "error\.headers" .
./tests/test_core.py:    assert error.headers == {"X-Foo": "bar"}
@sloria

This comment has been minimized.

Copy link
Member

commented Feb 2, 2019

In those cases, error is not a ValidationError. They are framework-specific HTTP exceptions.

@sloria sloria closed this Feb 2, 2019

sloria added a commit that referenced this issue Feb 2, 2019

@sloria

This comment has been minimized.

Copy link
Member

commented Feb 2, 2019

There was one incorrect usage in the docs, which is fixed now.

@decaz

This comment has been minimized.

Copy link
Author

commented Feb 2, 2019

@sloria isn't it ValidationError in use in the following methods?

raise LookupError("No exception for {0}".format(error.status_code))

raise LookupError("Status code {0} not supported".format(error.status_code))

For AIOHTTPParser I see there is
def handle_error(
self,
error: ValidationError,

We can replace them by error_status_code variable. And maybe there are also ValidationError objects within the test files I got by grep?

@sloria

This comment has been minimized.

Copy link
Member

commented Feb 2, 2019

Ah, I missed those.

I'll fix those and look at the other usages.

Thanks for looking into it.

@sloria sloria reopened this Feb 2, 2019

@sloria sloria closed this in 62d8ccb Feb 2, 2019

@sloria

This comment has been minimized.

Copy link
Member

commented Feb 2, 2019

Looks like those two were the only remaining usages. The other matches of your grep were for HTTP exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.