Table of Contents
BaseRenderersanic.errorpagesHTMLRenderersanic.errorpagesJSONRenderersanic.errorpagesTextRenderersanic.errorpagescheck_error_formatsanic.errorpagesescapesanic.errorpagesexception_responsesanic.errorpagesguess_mimesanic.errorpagessanic.errorpages.BaseRenderer#
Base class that all renderers must inherit from.
class BaseRenderer(request: Request, exception: Exception, debug: bool)
This class defines the structure for rendering objects, handling the core functionality that specific renderers may extend.
Parameters
- request
Request The incoming request object that needs rendering.
- exception
Exception Any exception that occurred and needs to be rendered.
- debug
bool Flag indicating whether to render with debugging information.
- request
Request The incoming request object that needs rendering.
- exception
Exception Any exception that occurred and needs to be rendered.
- debug
bool Flag indicating whether to render with debugging information.
full#
Provide a formatted message that has all details and is mean to be used primarily for debugging and non-production environments.
def full(self): -> HTTPResponse
Return
- HTTPResponse
The response object.
minimal#
Provide a formatted message that is meant to not show any sensitive data or details.
def minimal(self): -> HTTPResponse
This is the default fallback for production environments.
Return
- HTTPResponse
The response object.
render#
Outputs the exception as a response.
def render(self): -> HTTPResponse
Return
- HTTPResponse
The response object.
sanic.errorpages.HTMLRenderer#
Render an exception as HTML.
class HTMLRenderer(request: Request, exception: Exception, debug: bool)
The default fallback type.
full#
Provide a formatted message that has all details and is mean to be used primarily for debugging and non-production environments.
def full(self): -> HTTPResponse
Return
- HTTPResponse
The response object.
minimal#
Provide a formatted message that is meant to not show any sensitive data or details.
def minimal(self): -> HTTPResponse
This is the default fallback for production environments.
Return
- HTTPResponse
The response object.
render#
Outputs the exception as a response.
def render(self): -> HTTPResponse
Return
- HTTPResponse
The response object.
sanic.errorpages.JSONRenderer#
Render an exception as JSON.
class JSONRenderer(request: Request, exception: Exception, debug: bool)
full#
Provide a formatted message that has all details and is mean to be used primarily for debugging and non-production environments.
def full(self): -> HTTPResponse
Return
- HTTPResponse
The response object.
minimal#
Provide a formatted message that is meant to not show any sensitive data or details.
def minimal(self): -> HTTPResponse
This is the default fallback for production environments.
Return
- HTTPResponse
The response object.
render#
Outputs the exception as a response.
def render(self): -> HTTPResponse
Return
- HTTPResponse
The response object.
sanic.errorpages.TextRenderer#
Render an exception as plain text.
class TextRenderer(request: Request, exception: Exception, debug: bool)
full#
Provide a formatted message that has all details and is mean to be used primarily for debugging and non-production environments.
def full(self): -> HTTPResponse
Return
- HTTPResponse
The response object.
minimal#
Provide a formatted message that is meant to not show any sensitive data or details.
def minimal(self): -> HTTPResponse
This is the default fallback for production environments.
Return
- HTTPResponse
The response object.
render#
Outputs the exception as a response.
def render(self): -> HTTPResponse
Return
- HTTPResponse
The response object.
sanic.errorpages.escape#
Minimal HTML escaping, not for attribute values (unlike html.escape).
def escape(text)
sanic.errorpages.exception_response#
Render a response for the default FALLBACK exception handler.
def exception_response(request: Request, exception: Exception, debug: bool, fallback: str, base: t.Type[BaseRenderer], renderer: t.Optional[t.Type[BaseRenderer]] = None): -> HTTPResponse
sanic.errorpages.guess_mime#
Guess the MIME type for the response based upon the request.
def guess_mime(req: Request, fallback: str): -> str