|
Moodle PHP Documentation 5.0
Moodle 5.0.1+ (Build: 20250711) (61af040cd5f)
|
Default Slim application error handler. More...
Public Member Functions | |
| __construct (CallableResolverInterface $callableResolver, ResponseFactoryInterface $responseFactory, ?LoggerInterface $logger=null) | |
| __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 |
Default Slim application error handler.
It outputs the error message and diagnostic information in one of the following formats: JSON, XML, Plain Text or HTML based on the Accept header.
| Slim\Handlers\ErrorHandler::__invoke | ( | ServerRequestInterface | $request, |
| Throwable | $exception, | ||
| bool | $displayErrorDetails, | ||
| bool | $logErrors, | ||
| bool | $logErrorDetails ) |
Invoke error handler.
| ServerRequestInterface | $request | The most recent Request object |
| Throwable | $exception | The caught Exception object |
| bool | $displayErrorDetails | Whether or not to display the error details |
| bool | $logErrors | Whether or not to log errors |
| bool | $logErrorDetails | Whether or not to log error details |
Implements Slim\Interfaces\ErrorHandlerInterface.
|
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 in core\router\error_handler.
|
protected |
Determine which renderer to use based on content type.
| RuntimeException |
| Slim\Handlers\ErrorHandler::forceContentType | ( | ?string | $contentType | ) |
Force the content type for all error handler responses.
| string | null | $contentType | The content type |
| Slim\Handlers\ErrorHandler::registerErrorRenderer | ( | string | $contentType, |
| $errorRenderer ) |
Register an error renderer for a specific content-type.
| string | $contentType | The content-type this renderer should be registered to |
| ErrorRendererInterface | string | callable | $errorRenderer | The error renderer |
| Slim\Handlers\ErrorHandler::setDefaultErrorRenderer | ( | string | $contentType, |
| $errorRenderer ) |
Set the default error renderer.
| string | $contentType | The content type of the default error renderer |
| ErrorRendererInterface | string | callable | $errorRenderer | The default error renderer |
| Slim\Handlers\ErrorHandler::setLogErrorRenderer | ( | $logErrorRenderer | ) |
Set the renderer for the error logger.
| ErrorRendererInterface | string | callable | $logErrorRenderer |
|
protected |