private static function stackTrace(\PDOException $e, $show = true)
{
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$jarr['timer'] = '15000';
$jarr['status'] = 'no';
$jarr['info']['stack'][$i = 0] = '<strong>Exception:</strong> ' . $e->getMessage() . '<br />';
foreach ($e->getTrace() as $t) {
$jarr['info']['stack'][$i] = '#' . $i++ . ' ' . basename($t['file']) . ':' . $t['line'];
}
$json_stack = json_encode($jarr, true);
exit($json_stack);
} else {
if (defined('PHPUnit_MAIN_METHOD')) {
return;
}
if (static::PDO4YOU_FIREDEBUG == FALSE) {
return;
}
self::css();
if (defined(static::PDO4YOU_WEBMASTER)) {
self::fireAlert(self::$exception['critical-error'], $e);
}
$count = 0;
$stack = '<div class="pdo4you">';
$stack .= '<strong> Exception:</strong> ' . $e->getMessage() . '<br />';
if ($show) {
foreach ($e->getTrace() as $t) {
$stack .= '<div class="code title">#' . $count++ . ' <span>' . $t['file'] . ':' . $t['line'] . '</span></div><div class="code trace">' . self::highlightSource($t['file'], $t['line']) . '</div>';
}
}
$stack .= '</div>';
exit($stack);
}
}