‪TYPO3CMS  11.5
TYPO3\CMS\Core\Error\ErrorHandler Class Reference
Inheritance diagram for TYPO3\CMS\Core\Error\ErrorHandler:
TYPO3\CMS\Core\Error\ErrorHandlerInterface

Public Member Functions

 __construct ($errorHandlerErrors)
 
 setExceptionalErrors ($exceptionalErrors)
 
 setDebugMode ($debugMode)
 
 registerErrorHandler ()
 
bool handleError ($errorLevel, $errorMessage, $errorFile, $errorLine)
 

Protected Member Functions

 createAndEnqueueFlashMessage (string $message, int $errorLevel)
 
 writeLog ($logMessage, string $logLevel)
 
 getFormattedLogMessage (string $message)
 
 getTimeTracker ()
 
 getBackendUser ()
 

Protected Attributes

int $exceptionalErrors = 0
 
int $errorHandlerErrors = 0
 
bool $debugMode = false
 
const ERROR_LEVEL_LABELS
 

Additional Inherited Members

- ‪Public Attributes inherited from ‪TYPO3\CMS\Core\Error\ErrorHandlerInterface
const ERROR_HANDLED = true
 
const PROPAGATE_ERROR = false
 

Detailed Description

Global error handler for TYPO3

This file is a backport from TYPO3 Flow

Definition at line 39 of file ErrorHandler.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Error\ErrorHandler::__construct (   $errorHandlerErrors)

Registers this class as default error handler

Parameters
int$errorHandlerErrors‪The integer representing the E_* error level which should be

Implements TYPO3\CMS\Core\Error\ErrorHandlerInterface.

Definition at line 75 of file ErrorHandler.php.

References TYPO3\CMS\Core\Error\ErrorHandler\$errorHandlerErrors.

Member Function Documentation

◆ createAndEnqueueFlashMessage()

TYPO3\CMS\Core\Error\ErrorHandler::createAndEnqueueFlashMessage ( string  $message,
int  $errorLevel 
)
protected

◆ getBackendUser()

TYPO3\CMS\Core\Error\ErrorHandler::getBackendUser ( )
protected

Definition at line 285 of file ErrorHandler.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Error\ErrorHandler\writeLog().

◆ getFormattedLogMessage()

TYPO3\CMS\Core\Error\ErrorHandler::getFormattedLogMessage ( string  $message)
protected

◆ getTimeTracker()

TYPO3\CMS\Core\Error\ErrorHandler::getTimeTracker ( )
protected

Definition at line 280 of file ErrorHandler.php.

Referenced by TYPO3\CMS\Core\Error\ErrorHandler\handleError().

◆ handleError()

bool TYPO3\CMS\Core\Error\ErrorHandler::handleError (   $errorLevel,
  $errorMessage,
  $errorFile,
  $errorLine 
)

Handles an error. If the error is registered as exceptionalError it will by converted into an exception, to be handled by the configured exceptionhandler. Additionally the error message is written to the configured logs. If application is backend, the error message is also added to the flashMessageQueue, in frontend the error message is displayed in the admin panel (as TsLog message).

Parameters
int$errorLevel‪The error level - one of the E_* constants
string$errorMessage‪The error message
string$errorFile‪Name of the file the error occurred in
int$errorLine‪Line number where the error occurred
Returns
‪bool
Exceptions
Exception‪with the data passed to this method if the error is registered as exceptionalError

Implements TYPO3\CMS\Core\Error\ErrorHandlerInterface.

Definition at line 122 of file ErrorHandler.php.

References $GLOBALS, TYPO3\CMS\Core\Error\ErrorHandler\createAndEnqueueFlashMessage(), TYPO3\CMS\Core\Error\ErrorHandlerInterface\ERROR_HANDLED, TYPO3\CMS\Core\Error\ErrorHandler\getFormattedLogMessage(), TYPO3\CMS\Core\Error\ErrorHandler\getTimeTracker(), TYPO3\CMS\Core\Error\ErrorHandlerInterface\PROPAGATE_ERROR, and TYPO3\CMS\Core\Error\ErrorHandler\writeLog().

◆ registerErrorHandler()

TYPO3\CMS\Core\Error\ErrorHandler::registerErrorHandler ( )

Definition at line 103 of file ErrorHandler.php.

◆ setDebugMode()

TYPO3\CMS\Core\Error\ErrorHandler::setDebugMode (   $debugMode)
Parameters
bool$debugMode

Definition at line 98 of file ErrorHandler.php.

References TYPO3\CMS\Core\Error\ErrorHandler\$debugMode.

◆ setExceptionalErrors()

TYPO3\CMS\Core\Error\ErrorHandler::setExceptionalErrors (   $exceptionalErrors)

Defines which error levels should result in an exception thrown.

Parameters
int$exceptionalErrors‪The integer representing the E_* error level to handle as exceptions

Implements TYPO3\CMS\Core\Error\ErrorHandlerInterface.

Definition at line 87 of file ErrorHandler.php.

References TYPO3\CMS\Core\Error\ErrorHandler\$exceptionalErrors.

◆ writeLog()

TYPO3\CMS\Core\Error\ErrorHandler::writeLog (   $logMessage,
string  $logLevel 
)
protected

Writes an error in the sys_log table

Parameters
string$logMessage‪Default text that follows the message (in english!).
string$logLevel‪The error level, see LogLevel::* constants

Definition at line 217 of file ErrorHandler.php.

References $GLOBALS, and TYPO3\CMS\Core\Error\ErrorHandler\getBackendUser().

Referenced by TYPO3\CMS\Core\Error\ErrorHandler\handleError().

Member Data Documentation

◆ $debugMode

bool TYPO3\CMS\Core\Error\ErrorHandler::$debugMode = false
protected

Whether to write a flash message in case of an error

Definition at line 56 of file ErrorHandler.php.

Referenced by TYPO3\CMS\Core\Error\ErrorHandler\setDebugMode().

◆ $errorHandlerErrors

int TYPO3\CMS\Core\Error\ErrorHandler::$errorHandlerErrors = 0
protected

Error levels which should be handled.

Definition at line 51 of file ErrorHandler.php.

Referenced by TYPO3\CMS\Core\Error\ErrorHandler\__construct().

◆ $exceptionalErrors

int TYPO3\CMS\Core\Error\ErrorHandler::$exceptionalErrors = 0
protected

Error levels which should result in an exception thrown.

Definition at line 46 of file ErrorHandler.php.

Referenced by TYPO3\CMS\Core\Error\ErrorHandler\setExceptionalErrors().

◆ ERROR_LEVEL_LABELS

const TYPO3\CMS\Core\Error\ErrorHandler::ERROR_LEVEL_LABELS
protected
Initial value:
= [
E_WARNING => 'PHP Warning',
E_NOTICE => 'PHP Notice',
E_USER_ERROR => 'PHP User Error',
E_USER_WARNING => 'PHP User Warning',
E_USER_NOTICE => 'PHP User Notice',
E_STRICT => 'PHP Runtime Notice',
E_RECOVERABLE_ERROR => 'PHP Catchable Fatal Error',
E_USER_DEPRECATED => 'TYPO3 Deprecation Notice',
E_DEPRECATED => 'PHP Runtime Deprecation Notice',
]

Definition at line 58 of file ErrorHandler.php.