    def write_error(self, status_code: int, **kwargs: Any) -> None:
        """Override to implement custom error pages.

        ``write_error`` may call `write`, `render`, `set_header`, etc
        to produce output as usual.

        If this error was caused by an uncaught exception (including
        HTTPError), an ``exc_info`` triple will be available as
        ``kwargs["exc_info"]``.  Note that this exception may not be
        the "current" exception for purposes of methods like
        ``sys.exc_info()`` or ``traceback.format_exc``.
        """
        status_code = int(status_code)
        code_and_message_map = {
            400: "Bad Request",
            401: "Unauthorized Request",
            # 403: self._reason,
            404: "404 Not Found",
            405: "405 Method Not Allowed",
        }

        self.set_status(status_code)
        self.finish(
            self.jsonify(
                status="error",
                message=code_and_message_map.get(status_code, self._reason),
            )
        )
Override to implement custom error pages.

``write_error`` may call `write`, `render`, `set_header`, etc
to produce output as usual.

If this error was caused by an uncaught exception (including
HTTPError), an ``exc_info`` triple will be available as
``kwargs["exc_info"]``.  Note that this exception may not be
the "current" exception for purposes of methods like
``sys.exc_info()`` or ``traceback.format_exc``.
bgmi/front/base.py