' . $exception->getLine() . ''
. '
'
. '' . nl2br(strip_tags($exception->getMessage())) . ''
. '
';
if ($exception instanceof Zend_Db_Statement_Exception
&& false !== ($lastQueryProfile = Qs_Db::getInstance()->getProfiler()->getLastQueryProfile())
) {
$html .= '
Last query:
'
. formatSql($lastQueryProfile->getQuery())
. '
';
}
return $html;
}
/**
* @param Exception $exception
* @return string
*/
public static function getExceptionBacktrace($exception)
{
$debugBacktrace = $exception->getTrace();
$debugBacktrace = Qs_Debug::_removeObjects($debugBacktrace);
return 'BACKTRACE
' . print_r($debugBacktrace, true) . '
';
}
protected function _sendExceptionNotification($exception)
{
$message = Qs_Debug::getExceptionMessage($exception);
$backtrace = Qs_Debug::getExceptionBacktrace($exception);
$html = $message
. '
'
. 'URL: ' . Qs_Request::getUrl() . '';
foreach (array('_GET', '_POST', '_COOKIE', '_SERVER', '_ENV') as $name) {
$html .= '
$' . $name . '
' . htmlspecialchars(print_r($GLOBALS[$name], true)) . '
';
}
$html .= '
' . $backtrace;
$notifyEmails = $this->getOption('notifyEmails');
if (is_array($notifyEmails) && !empty($notifyEmails)) {
$headers = 'From: debug@' . $_SERVER['SERVER_NAME'] . "\n"
. 'Reply-To: no-reply@' . $_SERVER['SERVER_NAME'] . "\n"
. 'Content-Type: text/html' . "\n"
. 'X-Mailer: PHP/' . phpversion();
foreach ($notifyEmails as $email) {
mail($email, 'Error Dump from ' . $_SERVER['SERVER_NAME'], $html, $headers);
}
}
return $this;
}
/**
* @param Exception $exception
*/
public function exceptionHandler($exception)
{
$message = Qs_Debug::getExceptionMessage($exception);
$backtrace = Qs_Debug::getExceptionBacktrace($exception);
$this->_writeLog($exception->getMessage(), 0);
if (Qs_Constant::get('DEBUG')) {
die($message . '
'. $backtrace);
}
$this->_sendExceptionNotification($exception);
die('Internal error');
}
public static function processException($exception)
{
Qs_Debug::getInstance()->exceptionHandler($exception);
}
}