Feature #20735

Improve error handling for tslib_fe->printError and die()

Added by Jeff Segars almost 12 years ago. Updated almost 11 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Sprint Focus:


Currently, TYPO3 handles severe errors in two ways. In a frontend context, tslib_fe->printError() is used to show a nicely formatted error message to the user. The call to printError() is typically accompanied by a corresponding sysLog entry and a 404 or 503 header to let the browser know this was not the expected result [1]. In the backend context, a simple die() is used with no specific headers or sysLog entries [2].

I would propose a new printError() method that is valid in both a frontend and backend context (the current method is actually a wrapper for a method in t3lib_timetrack which makes no sense to me). In addition to the current HTML output, it should handle the sysLog entry, HTTP headers, and exit. It should also check for CLI mode and output a simple text message in this case rather than the full HTML.

[1] From tslib_fe->connectToDB()
$message = 'Cannot connect to the current database, "'.TYPO3_db.'"';
t3lib_div::sysLog($message, 'cms', t3lib_div::SYSLOG_SEVERITY_ERROR);
header('HTTP/1.0 503 Service Temporarily Unavailable');
$this->printError($message, 'Database Error');

[2] from t3lib_extMgm::extPath()
if (!isset($TYPO3_LOADED_EXT[$key])) {
die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extPath)');

(issue imported from #M11501)

Related issues

Related to TYPO3 Core - Bug #21168: Improve the error and exception handlingClosedRupert Germann2009-10-01

Related to TYPO3 Core - Bug #22420: Do not die, be the exception!ClosedSteffen Kamper2010-04-11


Updated by Jeff Segars about 11 years ago

This has been fixed by the error handler introduced in 4.3 and the removal of the die() messages in 4.4, both flagged as related issues to this one.

Also available in: Atom PDF