Skip to content

Commit

Permalink
fix bad request json use single quote
Browse files Browse the repository at this point in the history
  • Loading branch information
wuttinanhi committed Oct 24, 2022
1 parent 0b39890 commit 996833c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
main
"""


from http.client import BAD_REQUEST, INTERNAL_SERVER_ERROR

from flask import Flask, request
Expand Down Expand Up @@ -69,9 +68,10 @@ def hello_world():
def error_handle(err: Exception):
# web error
if issubclass(type(err), ValidationError):
return str(err), BAD_REQUEST
err: ValidationError = err
return err.messages_dict, BAD_REQUEST
if issubclass(type(err), HTTPException):
return {"error": err.description}, err.code
return {"error": str(err.description)}, err.code
# internal error
print(err)
return {"error": "Internal server exception!"}, INTERNAL_SERVER_ERROR
Expand Down
19 changes: 19 additions & 0 deletions thunder-tests/thunderclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -790,5 +790,24 @@
"form": []
},
"tests": []
},
{
"_id": "13d1c14c-7502-4200-9299-9987b434cc33",
"colId": "55d84e90-6849-46a6-b752-48f30ef9a83c",
"containerId": "",
"name": "login (invalid)",
"url": "{{BASE_API_URL}}/auth/login",
"method": "POST",
"sortNum": 40000,
"created": "2022-10-24T20:33:23.941Z",
"modified": "2022-10-24T20:33:45.643Z",
"headers": [],
"params": [],
"body": {
"type": "json",
"raw": "{\n \"email\": \"annie@\",\n \"password\": \"annie-password\"\n}",
"form": []
},
"tests": []
}
]

0 comments on commit 996833c

Please sign in to comment.