[TYPO3-project-4-3] Improve error handling for tslib_fe->printError() and die()
Jeff Segars
jsegars at alumni.rice.edu
Tue Jul 7 22:28:28 CEST 2009
Hey guys,
In the past few weeks we've realized how nice it is to keep an eye on
client sites by monitoring output from TYPO3's sysLog. It's been really
convenient as it gives us a quick view of problems that don't
necessarily generate PHP errors.
The parts that are really nice have opened our eyes to a few areas that
could use some improvement as well. Specifically, there are quite a few
places in the core that just die() without writing anything into the
sysLog (t3lib_extMgm::extPath() for example).
I'd like to improve this for 4.3 so I've opened up a feature request at
[1] and will include the text below. I'm curious what ideas you have and
wonder how exceptions might fit in here too.
Thanks,
Jeff
[1] http://bugs.typo3.org/view.php?id=11501
===========================================
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)');
}
More information about the TYPO3-project-4-3
mailing list