Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
core\router\error_handler Class Reference
Inheritance diagram for core\router\error_handler:
Slim\Handlers\ErrorHandler Slim\Interfaces\ErrorHandlerInterface

Public Member Functions

 __construct (App $app,)
 Construct a new Error Handler.
 
 __invoke (ServerRequestInterface $request, Throwable $exception, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails)
 Invoke error handler.
 
 forceContentType (?string $contentType)
 Force the content type for all error handler responses.
 
 registerErrorRenderer (string $contentType, $errorRenderer)
 Register an error renderer for a specific content-type.
 
 setDefaultErrorRenderer (string $contentType, $errorRenderer)
 Set the default error renderer.
 
 setLogErrorRenderer ($logErrorRenderer)
 Set the renderer for the error logger.
 

Protected Member Functions

 determineContentType (ServerRequestInterface $request)
 Determine which content type we know about is wanted using Accept header.
 
 determineRenderer ()
 Determine which renderer to use based on content type.
 
 determineStatusCode ()
 
 getDefaultLogger ()
 Returns a default logger implementation.
 
 logError (string $error)
 Wraps the error_log function so that this can be easily tested.
 
 respond ()
 
 writeToErrorLog ()
 Write to the error log if $logErrors has been set to true.
 

Protected Attributes

CallableResolverInterface $callableResolver
 
string $contentType = null
 
ErrorRendererInterface string callable $defaultErrorRenderer = HtmlErrorRenderer::class
 
string $defaultErrorRendererContentType = 'text/html'
 
bool $displayErrorDetails = false
 
array< string|callable > array $errorRenderers
 
Throwable $exception
 
bool $logErrorDetails = false
 
ErrorRendererInterface string callable $logErrorRenderer = PlainTextErrorRenderer::class
 
bool $logErrors
 
LoggerInterface $logger
 
string $method = null
 
ServerRequestInterface $request
 
ResponseFactoryInterface $responseFactory
 
int $statusCode
 

Constructor & Destructor Documentation

◆ __construct()

core\router\error_handler::__construct ( App $app)

Construct a new Error Handler.

Parameters
Slim\App$app

Member Function Documentation

◆ __invoke()

Slim\Handlers\ErrorHandler::__invoke ( ServerRequestInterface $request,
Throwable $exception,
bool $displayErrorDetails,
bool $logErrors,
bool $logErrorDetails )
inherited

Invoke error handler.

Parameters
ServerRequestInterface$requestThe most recent Request object
Throwable$exceptionThe caught Exception object
bool$displayErrorDetailsWhether or not to display the error details
bool$logErrorsWhether or not to log errors
bool$logErrorDetailsWhether or not to log error details

Implements Slim\Interfaces\ErrorHandlerInterface.

◆ determineContentType()

core\router\error_handler::determineContentType ( ServerRequestInterface $request)
protected

Determine which content type we know about is wanted using Accept header.

Note: This method is a bare-bones implementation designed specifically for Slim's error handling requirements. Consider a fully-feature solution such as willdurand/negotiation for any other situation.

Reimplemented from Slim\Handlers\ErrorHandler.

◆ determineRenderer()

Slim\Handlers\ErrorHandler::determineRenderer ( )
protectedinherited

Determine which renderer to use based on content type.

Exceptions
RuntimeException

◆ forceContentType()

Slim\Handlers\ErrorHandler::forceContentType ( ?string $contentType)
inherited

Force the content type for all error handler responses.

Parameters
string | null$contentTypeThe content type

◆ registerErrorRenderer()

Slim\Handlers\ErrorHandler::registerErrorRenderer ( string $contentType,
$errorRenderer )
inherited

Register an error renderer for a specific content-type.

Parameters
string$contentTypeThe content-type this renderer should be registered to
ErrorRendererInterface | string | callable$errorRendererThe error renderer

◆ setDefaultErrorRenderer()

Slim\Handlers\ErrorHandler::setDefaultErrorRenderer ( string $contentType,
$errorRenderer )
inherited

Set the default error renderer.

Parameters
string$contentTypeThe content type of the default error renderer
ErrorRendererInterface | string | callable$errorRendererThe default error renderer

◆ setLogErrorRenderer()

Slim\Handlers\ErrorHandler::setLogErrorRenderer ( $logErrorRenderer)
inherited

Set the renderer for the error logger.

Parameters
ErrorRendererInterface | string | callable$logErrorRenderer

Member Data Documentation

◆ $errorRenderers

array<string|callable> array Slim\Handlers\ErrorHandler::$errorRenderers
protectedinherited
Initial value:
= [
'application/json' => JsonErrorRenderer::class,
'application/xml' => XmlErrorRenderer::class,
'text/xml' => XmlErrorRenderer::class,
'text/html' => HtmlErrorRenderer::class,
'text/plain' => PlainTextErrorRenderer::class,
]

The documentation for this class was generated from the following file: