Skip to content
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

API - Handle errors gracefully #64

Open
nlehuby opened this issue Mar 28, 2019 · 0 comments
Open

API - Handle errors gracefully #64

nlehuby opened this issue Mar 28, 2019 · 0 comments
Labels
api enhancement New feature or request

Comments

@nlehuby
Copy link
Member

nlehuby commented Mar 28, 2019

When a route has no geometry yet, our API cannot handle it properly: we then get a 500 INTERNAL SERVER ERROR

our python part returns

[2019-03-28 13:27:37,855] ERROR in app: Exception on /routes/3383511 [GET]
api_1       | Traceback (most recent call last):
api_1       |   File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
api_1       |     rv = self.dispatch_request()
api_1       |   File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
api_1       |     return self.view_functions[rule.endpoint](**req.view_args)
api_1       |   File "/usr/local/lib/python3.5/site-packages/flask_restful/__init__.py", line 458, in wrapper
api_1       |     resp = resource(*args, **kwargs)
api_1       |   File "/usr/local/lib/python3.5/site-packages/flask/views.py", line 88, in view
api_1       |     return self.dispatch_request(*args, **kwargs)
api_1       |   File "/usr/local/lib/python3.5/site-packages/flask_restful/__init__.py", line 573, in dispatch_request
api_1       |     resp = meth(*args, **kwargs)
api_1       |   File "/api/api.py", line 247, in get
api_1       |     r["geometry"] = ast.literal_eval(get_route_geojson(route_id))
api_1       |   File "/usr/local/lib/python3.5/ast.py", line 84, in literal_eval
api_1       |     return _convert(node_or_string)
api_1       |   File "/usr/local/lib/python3.5/ast.py", line 83, in _convert
api_1       |     raise ValueError('malformed node or string: ' + repr(node))
api_1       | ValueError: malformed node or string: None
api_1       | 172.25.0.5 - - [28/Mar/2019:13:27:37 +0000] "GET /routes/3383511 HTTP/1.0" 500 37 "-" "Wget/1.17.1 (linux-gnu)"

Not sure about what we should return for the geojson part, but I think we should not fail on this, and be able to return a partial answer (with at least the route metadata)

@nlehuby nlehuby added enhancement New feature or request api labels Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant