Skip to content

Commit

Permalink
return error message if node not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed Jan 2, 2025
1 parent 9c18eac commit 046a296
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions backend/app/get_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def get_node(node_id, conflate_with_centreline=False):
with getConnection() as connection:
with connection.cursor() as cursor:
cursor.execute(SQL, {"node_id": node_id})
if cursor.rowcount != 1:
return None
geojson, street_names = cursor.fetchone()
node = {
'node_id': node_id,
Expand Down
4 changes: 2 additions & 2 deletions backend/app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def node(node_id):
doConflation = False
if request.args.get('doConflation') is not None:
doConflation = True

return jsonify(get_node(node_id, doConflation))
node = get_node(node_id, doConflation)
return jsonify(node if node else {'error': 'node not found'})

# test URL /link-nodes/here/30421154/30421153
#shell function - outputs json for use on frontend
Expand Down

0 comments on commit 046a296

Please sign in to comment.