Database Exceptions not Extendable |
|||
|---|---|---|---|
| Date: | 04/15/2008 | Severity: | Trivial |
| Status: | Resolved | Reporter: | inparo |
| Version: | 1.6.2 SVN | ||
| Keywords: | Libraries, Database Class | ||
| Forum Thread: | http://codeigniter.com/forums/viewreply/382419/ | ||
Description
Every method in the Exceptions class can be overridden except for the db error.
The database class falls out of line, because it instantiates a new CI_Exceptions object, thus bypassing the custom library.
Possible fix:
function display_error($error = '', $swap = '', $native = FALSE)
{
$LANG =& load_class('Language');
$LANG->load('db');
$heading = 'Database Error';
if ($native == TRUE)
{
$message = $error;
}
else
{
$message = ( ! is_array($error)) ? array(str_replace('%s', $swap, $LANG->line($error))) : $error;
}
$EXC =& load_class('Exceptions');
echo $EXC->show_error($heading, $message, 'error_db');
exit;
}
Expected Result
Actual Result
Comment on Bug Report
| Posted by: Derek Jones on 11 May 2008 6:47pm | |
|
|
The Language class will always be instantiated, so in the committed fix it simply references the global $LANG object. Other than that, your fix looks good, thank you. I’ve also added a language variable for the error heading. |
