Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
Slim\Middleware\ErrorMiddleware Class Reference
Inheritance diagram for Slim\Middleware\ErrorMiddleware:
Psr\Http\Server\MiddlewareInterface

Public Member Functions

 __construct (CallableResolverInterface $callableResolver, ResponseFactoryInterface $responseFactory, bool $displayErrorDetails, bool $logErrors, bool $logErrorDetails, ?LoggerInterface $logger=null)
 
 getDefaultErrorHandler ()
 Get default error handler.
 
 getErrorHandler (string $type)
 Get callable to handle scenarios where an error occurs when processing the current request.
 
 handleException (ServerRequestInterface $request, Throwable $exception)
 
 process (ServerRequestInterface $request, RequestHandlerInterface $handler)
 Process an incoming server request.
 
 setDefaultErrorHandler ($handler)
 Set callable as the default Slim application error handler.
 
 setErrorHandler ($typeOrTypes, $handler, bool $handleSubclasses=false)
 Set callable to handle scenarios where an error occurs when processing the current request.
 

Protected Attributes

CallableResolverInterface $callableResolver
 
ErrorHandlerInterface callable string null $defaultErrorHandler
 
bool $displayErrorDetails
 
ErrorHandlerInterface[] callable[] string[] array $handlers = []
 
bool $logErrorDetails
 
bool $logErrors
 
LoggerInterface $logger = null
 
ResponseFactoryInterface $responseFactory
 
ErrorHandlerInterface[] callable[] string[] array $subClassHandlers = []
 

Member Function Documentation

◆ getDefaultErrorHandler()

Slim\Middleware\ErrorMiddleware::getDefaultErrorHandler ( )

Get default error handler.

Return values
ErrorHandler|callable

◆ getErrorHandler()

Slim\Middleware\ErrorMiddleware::getErrorHandler ( string $type)

Get callable to handle scenarios where an error occurs when processing the current request.

Parameters
string$typeException/Throwable name. ie: RuntimeException::class
Return values
callable|ErrorHandler

◆ process()

Slim\Middleware\ErrorMiddleware::process ( ServerRequestInterface $request,
RequestHandlerInterface $handler )

Process an incoming server request.

Processes an incoming server request in order to produce a response. If unable to produce the response itself, it may delegate to the provided request handler to do so.

Implements Psr\Http\Server\MiddlewareInterface.

◆ setDefaultErrorHandler()

Slim\Middleware\ErrorMiddleware::setDefaultErrorHandler ( $handler)

Set callable as the default Slim application error handler.

The callable signature MUST match the ErrorHandlerInterface

See also
Slim\Interfaces\ErrorHandlerInterface
  1. Instance of Psr\Http\Message\ServerRequestInterface
  2. Instance of Throwable
  3. Boolean $displayErrorDetails
  4. Boolean $logErrors
  5. Boolean $logErrorDetails

The callable MUST return an instance of Psr\Http\Message\ResponseInterface.

Parameters
string | callable | ErrorHandler$handler

◆ setErrorHandler()

Slim\Middleware\ErrorMiddleware::setErrorHandler ( $typeOrTypes,
$handler,
bool $handleSubclasses = false )

Set callable to handle scenarios where an error occurs when processing the current request.

The callable signature MUST match the ErrorHandlerInterface

Pass true to $handleSubclasses to make the handler handle all subclasses of the type as well. Pass an array of classes to make the same function handle multiple exceptions.

See also
Slim\Interfaces\ErrorHandlerInterface
  1. Instance of Psr\Http\Message\ServerRequestInterface
  2. Instance of Throwable
  3. Boolean $displayErrorDetails
  4. Boolean $logErrors
  5. Boolean $logErrorDetails

The callable MUST return an instance of Psr\Http\Message\ResponseInterface.

Parameters
string | string[]$typeOrTypesException/Throwable name. ie: RuntimeException::class or an array of classes ie: [HttpNotFoundException::class, HttpMethodNotAllowedException::class]
string | callable | ErrorHandlerInterface$handler

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