No logging of exception

This commit is contained in:
Adam Hopkins 2023-01-26 17:12:51 +02:00
parent 2e36507a60
commit ca0e933813
No known key found for this signature in database
GPG Key ID: 9F85EE6C807303FB
3 changed files with 9 additions and 4 deletions

View File

@ -58,7 +58,7 @@ class DirectoryHandler:
@classmethod
def default_handler(
cls, request: Request, exception: SanicIsADirectoryError
) -> Optional[Union[HTTPResponse, Coroutine[Any, Any, HTTPResponse]]]:
) -> Optional[Coroutine[Any, Any, HTTPResponse]]:
if exception.autoindex or exception.index_name:
maybe_response = DirectoryHandler(
exception.location, exception.autoindex, exception.index_name

View File

@ -27,7 +27,12 @@ from sanic.base.meta import SanicMeta
from sanic.compat import stat_async
from sanic.constants import DEFAULT_HTTP_CONTENT_TYPE, HTTP_METHODS
from sanic.errorpages import RESPONSE_MAPPING
from sanic.exceptions import FileNotFound, HeaderNotFound, RangeNotSatisfiable
from sanic.exceptions import (
FileNotFound,
HeaderNotFound,
RangeNotSatisfiable,
SanicIsADirectoryError,
)
from sanic.handlers import ContentRangeHandler
from sanic.log import error_logger
from sanic.models.futures import FutureRoute, FutureStatic
@ -910,7 +915,7 @@ class RouteMixin(metaclass=SanicMeta):
autoindex=autoindex,
index_name=index_name,
)
except RangeNotSatisfiable:
except (RangeNotSatisfiable, SanicIsADirectoryError):
raise
except FileNotFoundError:
raise not_found

View File

@ -27,7 +27,7 @@ class BasePage(ABC):
@property
def style(self) -> str:
return f"{self.BASE_STYLE}\n{self.EXTRA_STYLE}"
return self.BASE_STYLE + self.EXTRA_STYLE
def render(self) -> str:
self._head()