Skip to content

Commit 5520ba3

Browse files
Merge pull request #80 from Geode-solutions/next
Next
2 parents 634980a + 040c409 commit 5520ba3

File tree

7 files changed

+59
-16
lines changed

7 files changed

+59
-16
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33

44

5+
## v4.2.0-rc.1 (2024-05-27)
6+
7+
### Feature
8+
9+
* feat(error_handler): Add handler ([`4dd7dfb`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/4dd7dfb8998403c27c2d04dfbdd64c16662704b1))
10+
11+
### Unknown
12+
13+
* Merge pull request #79 from Geode-solutions/feat_config
14+
15+
added test + handle_exception function ([`d0546b8`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/d0546b8203f48aac44491529b08f6d52b257767a))
16+
17+
* requirements ([`78faf30`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/78faf30ed1be63b009e1763b293ccfabc53f10c4))
18+
19+
* added test + handle_exception function ([`8f17937`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/8f17937dd05581ae9b6818b5a3a04abb1b95785f))
20+
21+
* ([`dca962e`](https://github.com/Geode-solutions/OpenGeodeWeb-Back/commit/dca962e5b0aed0366fa53ebe5ea074c9b3a65de6))
22+
23+
524
## v4.1.1 (2024-05-03)
625

726
### Unknown

app.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
import flask_cors
77
from werkzeug.exceptions import HTTPException
88

9-
from werkzeug.exceptions import HTTPException
10-
119
from src.opengeodeweb_back.routes import blueprint_routes
10+
from src.opengeodeweb_back.geode_functions import handle_exception
1211

1312

1413
""" Global config """
@@ -36,17 +35,16 @@
3635

3736

3837
@app.errorhandler(HTTPException)
39-
def handle_exception(e):
40-
response = e.get_response()
41-
response.data = flask.json.dumps(
42-
{
43-
"code": e.code,
44-
"name": e.name,
45-
"description": e.description,
46-
}
47-
)
48-
response.content_type = "application/json"
49-
return response
38+
def errorhandler(e):
39+
return handle_exception(e)
40+
41+
42+
@app.route(
43+
"/error",
44+
methods=["POST"],
45+
)
46+
def return_error():
47+
flask.abort(500, f"Test")
5048

5149

5250
# ''' Main '''

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "OpenGeodeWeb-Back"
8-
version = "4.1.1"
8+
version = "4.2.0-rc.1"
99
dynamic = ["dependencies"]
1010
authors = [
1111
{ name="Geode-solutions", email="[email protected]" },

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.10
33
# by the following command:
44
#
55
# pip-compile requirements.in
@@ -110,6 +110,8 @@ rpds-py==0.18.0
110110
# via
111111
# jsonschema
112112
# referencing
113+
typing-extensions==4.12.0
114+
# via asgiref
113115
werkzeug==3.0.2
114116
# via
115117
# -r requirements.in

src/opengeodeweb_back/geode_functions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,16 @@ def send_file(upload_folder, saved_files, new_file_name):
354354
response.headers["Access-Control-Expose-Headers"] = "new-file-name"
355355

356356
return response
357+
358+
359+
def handle_exception(e):
360+
response = e.get_response()
361+
response.data = flask.json.dumps(
362+
{
363+
"code": e.code,
364+
"name": e.name,
365+
"description": e.description,
366+
}
367+
)
368+
response.content_type = "application/json"
369+
return response

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def allowed_files():
3131
extensions = geode_functions.list_input_extensions(
3232
flask.request.json["supported_feature"]
3333
)
34-
return {"status": 200, "extensions": extensions}
34+
return flask.make_response({"extensions": extensions}, 200)
3535

3636

3737
with open(

tests/test_functions.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,14 @@ def test_extension_from_filename():
329329
extension = geode_functions.extension_from_filename("test.toto")
330330
assert type(extension) is str
331331
assert extension.count(".") == 0
332+
333+
334+
def test_handle_exception(client):
335+
route = "/error"
336+
response = client.post(route)
337+
assert response.status_code == 500
338+
data = response.get_json()
339+
assert type(data) is dict
340+
assert type(data["description"]) is str
341+
assert type(data["name"]) is str
342+
assert type(data["code"]) is int

0 commit comments

Comments
 (0)