Feature #20735
closedImprove error handling for tslib_fe->printError and die()
0%
Description
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');
exit;
[2] from t3lib_extMgm::extPath()
if (!isset($TYPO3_LOADED_EXT[$key])) {
#debug(array(debug_backtrace()));
die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extPath)');
}
(issue imported from #M11501)
Updated by Jeff Segars over 14 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.