Beispiel #1
0
 public function handlePDOException(PDOException $e)
 {
     trigger_error('PHP PDO Error in ' . $e->getFile() . ' @' . strval($e->getLine()) . ' [' . strval($e->getCode()) . '] :: ' . $e->getMessage(), E_USER_WARNING);
     foreach ($e->getTrace() as $a => $b) {
         foreach ($b as $c => $d) {
             if ($c == 'args') {
                 foreach ($d as $e => $f) {
                     trigger_error('PHP PDO Error trace: ' . strval($a) . '# args: ' . $e . ': ' . $f . '', E_USER_WARNING);
                 }
             } else {
                 trigger_error('PHP PDO Error trace: ' . strval($a) . '# ' . $c . ': ' . $d . '', E_USER_WARNING);
             }
         }
     }
 }
Beispiel #2
0
 public function __construct($message = "", $code = 0, \PDOException $previous = null)
 {
     if ($previous) {
         $this->message = $previous->message;
         $this->code = $previous->code;
         $this->file = $previous->file;
         $this->line = $previous->line;
         $this->trace = $previous->getTrace();
         $this->previous = $previous;
     }
     $backtrace = debug_backtrace();
     // We need directory separator for Windows
     $ipDbPath = 'Ip' . DIRECTORY_SEPARATOR . 'Db.php';
     $pathLength = strlen($ipDbPath);
     // We usually want exception to show error in the code that uses Db class
     foreach ($backtrace as $info) {
         if (substr($info['file'], -$pathLength) != $ipDbPath) {
             $this->file = $info['file'];
             $this->line = $info['line'];
             break;
         }
     }
 }
Beispiel #3
0
 private static function reportProblem(PDOException $e)
 {
     $trace = $e->getTrace();
     $DBcall = $trace[1];
     $functionCall = $trace[2];
     $type = 'error with DB';
     $function = $DBcall['function'] . ' into ' . $functionCall['function'] . ' in file ' . $functionCall['file'];
     $message = serialize($DBcall['args']);
     Db::queryModify('INSERT INTO tickets (`type`, `title`, `message`, `timestamp`)
                      VALUES (?,?,?,NOW())', [$type, $function, $message]);
 }
Beispiel #4
0
 /**
  * Method to display the stack trace of an error Exception
  * 
  * @access private static
  * @param \PDOException $e Gets the error stack generated by the exception
  * @param boolean $show Enables the display of the error stack
  * @return void
  */
 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>&nbsp;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);
     }
 }