mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-12 22:04:07 +00:00
fix error message for non-existing database
This commit is contained in:
@@ -61,6 +61,6 @@ async def get_status(engine: AsyncEngine) -> StatusResult:
|
||||
status.data_updated = await _get_database_date(conn)
|
||||
status.database_version = await _get_database_version(conn)
|
||||
except asyncpg.PostgresError:
|
||||
return StatusResult(700, 'No database')
|
||||
return StatusResult(700, 'Database connection failed')
|
||||
|
||||
return status
|
||||
|
||||
@@ -18,7 +18,10 @@ create = FormatDispatcher()
|
||||
|
||||
@create.format_func(StatusResult, 'text')
|
||||
def _format_status_text(result: StatusResult) -> str:
|
||||
return result.message
|
||||
if result.status:
|
||||
return f"ERROR: {result.message}"
|
||||
|
||||
return 'OK'
|
||||
|
||||
|
||||
@create.format_func(StatusResult, 'json')
|
||||
|
||||
@@ -65,6 +65,8 @@ class NominatimV1:
|
||||
result = await self.api.status()
|
||||
|
||||
self.format_response(req, resp, result)
|
||||
if result.status and req.context.format == 'text':
|
||||
resp.status = 500
|
||||
|
||||
|
||||
def get_application(project_dir: Path,
|
||||
|
||||
@@ -61,7 +61,13 @@ async def extract_format(request: sanic.Request) -> Optional[sanic.HTTPResponse]
|
||||
async def status(request: sanic.Request) -> sanic.HTTPResponse:
|
||||
""" Implementation of status endpoint.
|
||||
"""
|
||||
return api_response(request,await request.app.ctx.api.status())
|
||||
result = await request.app.ctx.api.status()
|
||||
response = api_response(request, result)
|
||||
|
||||
if request.ctx.format == 'text' and result.status:
|
||||
response.status = 500
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def get_application(project_dir: Path,
|
||||
|
||||
@@ -60,7 +60,12 @@ async def on_status(request: Request) -> Response:
|
||||
"""
|
||||
parse_format(request, StatusResult, 'text')
|
||||
result = await request.app.state.API.status()
|
||||
return format_response(request, result)
|
||||
response = format_response(request, result)
|
||||
|
||||
if request.state.format == 'text' and result.status:
|
||||
response.status_code = 500
|
||||
|
||||
return response
|
||||
|
||||
|
||||
V1_ROUTES = [
|
||||
|
||||
Reference in New Issue
Block a user