diff --git a/main.py b/main.py index 639f4c2..89a405c 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,6 @@ main """ - from http.client import BAD_REQUEST, INTERNAL_SERVER_ERROR from flask import Flask, request @@ -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 diff --git a/thunder-tests/thunderclient.json b/thunder-tests/thunderclient.json index 115c4fa..8df5da5 100644 --- a/thunder-tests/thunderclient.json +++ b/thunder-tests/thunderclient.json @@ -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": [] } ] \ No newline at end of file