Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Better handle 404 response for federation /send/ #1866
Conversation
erikjohnston
assigned
NegativeMjark
Jan 31, 2017
| def __enter__(self): | ||
| pass | ||
| def __exit__(self, exc_type, exc_val, exc_tb): | ||
| valid_err_code = False | ||
| if exc_type is not None and issubclass(exc_type, CodeMessageException): | ||
| - valid_err_code = exc_val.code != 429 and 0 <= exc_val.code < 500 | ||
| + if exc_val.code < 400: |
NegativeMjark
Jan 31, 2017
•
Contributor
Maybe chuck in a short comment explaining what's going on here? Just to explain what a valid_err_code is and why 404, 429 and >500 are special?
erikjohnston
added some commits
Jan 31, 2017
| + # APIs may expect to never received e.g. a 404. It's important to | ||
| + # handle 404 as some remote servers will return a 404 when the HS | ||
| + # has been decommissioned. | ||
| + if exc_val.code < 400: |
NegativeMjark
Jan 31, 2017
Contributor
Isn't the exc_val.code < 400 redundant because of the exc_val.code < 500 ?
erikjohnston
Jan 31, 2017
Owner
Yeah, though personally I quite like the fact that each case of code is handled in order. I can change it if you think it makes it clearer?
NegativeMjark
Jan 31, 2017
Contributor
I find it misleading because it makes it seem as though 4xx are handled differently to 2xx/3xx.
|
LGTM apart from the possibly redundant check? |
|
@matrixbot retest this please |
erikjohnston commentedJan 31, 2017
No description provided.