Пример #1
0
 /**
  * Check if $e is PEAR error, if so, throw as DbException
  *
  * @param $e PEAR_Error|array|object|int
  */
 private function assertError($e, $depth = 2)
 {
     if (!Misc::isError($e)) {
         return;
     }
     list($file, $line) = self::getTrace($depth);
     Error_Handler::logError(array($e->getMessage(), $e->getDebugInfo()), $file, $line);
     $de = new DbException($e->getMessage(), $e->getCode());
     $de->setExceptionLocation($file, $line);
     error_log($de->getMessage());
     error_log($de->getTraceAsString());
     throw $de;
 }
Пример #2
0
 /**
  * Check if $e is PEAR error, if so, throw as DbException
  *
  * @param $e PEAR_Error|array|object|int
  */
 private function assertError($e)
 {
     if (!Misc::isError($e)) {
         return;
     }
     $context = array('debuginfo' => $e->getDebugInfo());
     // walk up in $e->backtrace until we find ourself
     // and from it we can get method name and it's arguments
     foreach ($e->backtrace as $i => $stack) {
         if (!isset($stack['object'])) {
             continue;
         }
         if (!$stack['object'] instanceof self) {
             continue;
         }
         $context['method'] = $stack['function'];
         $context['arguments'] = $stack['args'];
         // add these last, they are least interesting ones
         $context['code'] = $e->getCode();
         $context['file'] = $stack['file'];
         $context['line'] = $stack['line'];
         break;
     }
     Logger::db()->error($e->getMessage(), $context);
     $de = new DbException($e->getMessage(), $e->getCode());
     if (isset($context['file'])) {
         $de->setExceptionLocation($context['file'], $context['line']);
     }
     throw $de;
 }