+class HTTPNominatimError(Exception):
+ """ A special exception class for errors raised during processing.
+ """
+ def __init__(self, msg: str, status: int, content_type: str) -> None:
+ self.msg = msg
+ self.status = status
+ self.content_type = content_type
+
+
+async def nominatim_error_handler(req: Request, resp: Response, #pylint: disable=unused-argument
+ exception: HTTPNominatimError,
+ _: Any) -> None:
+ """ Special error handler that passes message and content type as
+ per exception info.
+ """
+ resp.status = exception.status
+ resp.text = exception.msg
+ resp.content_type = exception.content_type
+
+
+class ParamWrapper(api_impl.ASGIAdaptor):
+ """ Adaptor class for server glue to Falcon framework.
+ """
+
+ def __init__(self, req: Request, resp: Response,
+ config: Configuration) -> None:
+ self.request = req
+ self.response = resp
+ self._config = config
+
+
+ def get(self, name: str, default: Optional[str] = None) -> Optional[str]:
+ return cast(Optional[str], self.request.get_param(name, default=default))
+
+
+ def get_header(self, name: str, default: Optional[str] = None) -> Optional[str]:
+ return cast(Optional[str], self.request.get_header(name, default=default))
+
+
+ def error(self, msg: str, status: int = 400) -> HTTPNominatimError:
+ return HTTPNominatimError(msg, status, self.content_type)