Skip to content

Commit 2c3228a

Browse files
authored
improve exception message for response validation error. (#33)
* improve exception message for response validation error.
1 parent 65b1f5f commit 2c3228a

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Version 0.18.1
2+
3+
* Improve exception message for response validation error.
4+
15
## Version 0.17.0
26

37
* Authorization via HTTPBasicAuth and Bearer token supported.

Makefile

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1+
VENV_DIR = venv
2+
PYTHON = python3.12
3+
PIP = $(VENV_DIR)/bin/pip
4+
PYTHON_VENV = $(VENV_DIR)/bin/python
5+
TOX = $(VENV_DIR)/bin/tox
6+
PRE_COMMIT = $(VENV_DIR)/bin/pre-commit
7+
8+
19
.PHONY: venv test tox format clean build install upload_to_testpypi upload_to_pypi all
210

311

4-
venv:
12+
venv: venv/pyvenv.cfg $(PKG_DIR)
513
# Create virtual environment.
6-
python3.12 -m venv venv
7-
./venv/bin/pip3 -q install --upgrade pip setuptools wheel
8-
./venv/bin/pip3 -q install -e ".[dev]"
9-
./venv/bin/pip3 -q install -e .
14+
15+
venv/pyvenv.cfg: pyproject.toml $(PKG_DIR)
16+
$(PYTHON) -m venv $(VENV_DIR)
17+
$(PIP) -q install --upgrade pip wheel
18+
$(PIP) -q install -e ".[dev]" && $(PIP) -q install -e .
1019

1120
format: venv
1221
# Run checking and formatting sources.
13-
./venv/bin/pre-commit run -a
22+
$(PRE_COMMIT) run -a
1423

1524
test: venv
1625
# Run pytest.
@@ -19,22 +28,22 @@ test: venv
1928

2029
tox: venv
2130
# Testing project via several Python versions.
22-
./venv/bin/tox
31+
$(TOX)
2332

2433
clean:
2534
rm -rf dist/
2635
rm -rf src/Flask_First.egg-info
2736

2837
build: clean venv
29-
./venv/bin/python3 -m build
38+
$(PYTHON_VENV) -m build
3039

3140
install: build
32-
./venv/bin/pip install dist/Flask-First-*.tar.gz
41+
$(PIP) install dist/Flask-First-*.tar.gz
3342

3443
upload_to_testpypi: build
35-
./venv/bin/python3 -m twine upload --repository testpypi dist/*
44+
$(PYTHON_VENV) -m twine upload --repository testpypi dist/*
3645

3746
upload_to_pypi: build
38-
./venv/bin/python3 -m twine upload --repository pypi dist/*
47+
$(PYTHON_VENV) -m twine upload --repository pypi dist/*
3948

4049
all: venv tox build

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ license = {file = "LICENSE"}
2323
name = "Flask-First"
2424
readme = "README.md"
2525
requires-python = ">=3.9"
26-
version = "0.18.0"
26+
version = "0.18.1"
2727

2828
[project.optional-dependencies]
2929
dev = [
30-
"bandit==1.7.7",
31-
"build==1.1.1",
32-
"mypy==1.8.0",
33-
"pre-commit==3.6.2",
34-
"pytest==8.1.2",
35-
"pytest-cov==4.1.0",
30+
"bandit==1.7.9",
31+
"build==1.2.1",
32+
"mypy==1.11.2",
33+
"pre-commit==3.8.0",
34+
"pytest==8.3.2",
35+
"pytest-cov==5.0.0",
3636
"python-dotenv==1.0.1",
37-
"tox==4.13.0",
38-
"twine==5.0.0"
37+
"tox==4.18.0",
38+
"twine==5.1.1"
3939
]
4040

4141
[project.urls]

src/flask_first/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,10 @@ def add_response_validating(response: Response) -> Response:
236236
else:
237237
json_schema().load(json)
238238
except ValidationError as e:
239-
raise FirstResponseJSONValidation(repr(e))
239+
raise FirstResponseJSONValidation(
240+
f'For <{method} {route}> and response body <{json}> raised error'
241+
f' <{repr(e)}>'
242+
)
240243

241244
return response
242245

0 commit comments

Comments
 (0)