Compare commits

..

1 commit
main ... main

Author SHA1 Message Date
ea2b3c18d8 Show Nominatim 403 error to user in Web UI
Closes #5

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-18 19:41:31 +00:00
2 changed files with 6 additions and 1 deletions

View file

@ -31,6 +31,8 @@ def lookup_with_params(**kwargs: str) -> list[Hit]:
r = requests.get(url, params=params, headers=user_agent_headers())
if r.status_code == 500:
raise SearchError
if r.status_code == 403:
raise SearchError("Nominatim returned 403 Forbidden")
try:
reply: list[Hit] = json.loads(r.text, object_pairs_hook=OrderedDict)

View file

@ -653,7 +653,10 @@ def api_missing_wikidata_items():
@app.route("/api/1/search")
def api_search():
q = flask.request.args["q"]
try:
hits = nominatim.lookup(q)
except nominatim.SearchError as e:
return cors_jsonify({"success": False, "error": str(e)}, 503)
for hit in hits:
hit["name"] = nominatim.get_hit_name(hit)
hit["label"] = nominatim.get_hit_label(hit)