Ejemplo n.º 1
0
 /**
  * Custom production database error handlers
  */
 private function setDatabaseErrorHandlers()
 {
     DB::$error_handler = function ($params) {
         /* @var $e Exception */
         $e = new Exception();
         $backtrace = preg_split("/[\r\n]+/", $e->getTraceAsString());
         //remove core traces
         foreach ($backtrace as $key => $line) {
             if (strpos($line, 'internal function') || strpos($line, 'DB.php')) {
                 unset($backtrace[$key]);
             } else {
                 break;
             }
         }
         //remove trace auto increment
         foreach ($backtrace as &$line) {
             $line = preg_replace("/^#\\d+ /", '', $line);
         }
         $backtrace = array_slice($backtrace, 0, -2);
         trigger_error(implode(PHP_EOL, $params) . PHP_EOL . implode(PHP_EOL, $backtrace), E_USER_WARNING);
     };
     DB::$nonsql_error_handler = function ($params) {
         trigger_error(implode(PHP_EOL, $params), E_USER_WARNING);
         header("HTTP/1.1 500 Internal Server Error");
         readfile(BASE_PATH . DS . '500.html');
         exit;
     };
 }