Show Nominatim 403 error to user in Web UI
Closes #5 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0d2cfd56cb
commit
ea2b3c18d8
2 changed files with 6 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -653,7 +653,10 @@ def api_missing_wikidata_items():
|
|||
@app.route("/api/1/search")
|
||||
def api_search():
|
||||
q = flask.request.args["q"]
|
||||
hits = nominatim.lookup(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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue