-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix HTTPException message #59
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we are passing the resp
object ref inside the Exception class so it will be good to hide the content_type check within the class for clarity, rather than putting it in the global _handler
.
We can't move the content_type check inside the class because you can't use |
In that case, we can just add those awaited values to the error obj before raising exception or we can add
|
If we REALLY want to avoid checking the response's content-type outside and put it inside the HTTPException class instead for the sake of making the code in So instead of if resp.status >= 400:
raise HTTPException(resp, await resp.json()) it's now if resp.status >= 400:
raise await HTTPException.create(resp) and the check and async reads are in the async |
Fix HTTPException erroring when getting content types other than
![image](https://private-user-images.githubusercontent.com/106537315/351867652-b69ec582-f855-468e-b496-01ce47e0a433.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNjU3OTMsIm5iZiI6MTczOTE2NTQ5MywicGF0aCI6Ii8xMDY1MzczMTUvMzUxODY3NjUyLWI2OWVjNTgyLWY4NTUtNDY4ZS1iNDk2LTAxY2U0N2UwYTQzMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMFQwNTMxMzNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02OGQ3Y2EzYzRjNzA0MGQxMjM1MTRiYzc4OTI1OTliMzdkMWEwMTI5Yjg4MTE1OGQ4Mjg0MDllODYyMmU5N2Y3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.UiLb7712AUSakydoSbWNGUuCJSOMP-q6xn_DwBAmvRA)
application/json
.Be more explicit with the response data. Sometimes it doesn't have the "code" key in it, but it is a valid json.
![image](https://private-user-images.githubusercontent.com/106537315/351867140-3f16c76d-9e51-4302-8203-cfee4bdeb3c0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNjU3OTMsIm5iZiI6MTczOTE2NTQ5MywicGF0aCI6Ii8xMDY1MzczMTUvMzUxODY3MTQwLTNmMTZjNzZkLTllNTEtNDMwMi04MjAzLWNmZWU0YmRlYjNjMC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMFQwNTMxMzNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZGQ3NmE4OTZiYTU0ZTk1ZGJlMjhiNTA3YjE3YTY1MjAyOGIyNTZiMjM5ODBhNTFjOWY5MjAzYjk4OTAwZjA3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.e-0uM1gvllccG-RfC_aUBLtRRI194jKGye2PwDqe6Sk)