示例#1
2
 public function handleErrorException(\ErrorException $exception)
 {
     $message = sprintf('%s: %s in %s:%d', $this->errorCodeName($exception->getCode()), $exception->getMessage(), $exception->getFile(), $exception->getLine());
     $exception_trace = $exception->getTraceAsString();
     $exception_trace = substr($exception_trace, strpos($exception_trace, PHP_EOL) + 1);
     $message .= PHP_EOL . $exception_trace;
     $this->save($message);
 }
示例#2
0
 protected function handleErrorException(\ErrorException $e)
 {
     switch ($e->getSeverity()) {
         case E_ERROR:
         case E_RECOVERABLE_ERROR:
         case E_CORE_ERROR:
         case E_COMPILE_ERROR:
         case E_USER_ERROR:
         case E_PARSE:
             $this->logger->error($e->getMessage() . $e->getTraceAsString());
             break;
         case E_WARNING:
         case E_USER_WARNING:
         case E_CORE_WARNING:
         case E_COMPILE_WARNING:
             $this->logger->warning($e->getMessage() . $e->getTraceAsString());
             break;
         case E_NOTICE:
         case E_USER_NOTICE:
             $this->logger->notice($e->getMessage() . $e->getTraceAsString());
             break;
         case E_STRICT:
         case E_DEPRECATED:
         case E_USER_DEPRECATED:
             $this->logger->info($e->getMessage() . $e->getTraceAsString());
             break;
     }
     return true;
 }
示例#3
0
 public function handleErrors(\ErrorException $e)
 {
     $severity = $this->determineSeverityTextValue($e->getSeverity());
     $message = $e->getMessage();
     $file = $e->getFile();
     $line = $e->getLine();
     $error = ['message' => $message, 'severity' => $severity, 'file' => $file, 'line' => $line];
     return $error;
 }
示例#4
0
 public function handleErrors(\ErrorException $e)
 {
     $severity = $this->determineSeverityTextValue($e->getSeverity());
     $type = 'Error (' . $severity . ')';
     $message = $e->getMessage();
     $file = $e->getFile();
     $line = $e->getLine();
     return $this->getHtml($type, $message, $file, $line);
 }
示例#5
0
 public function handleErrors(\ErrorException $e)
 {
     $errorString = "<strong>%s</strong>: %s in <strong>%s</strong> on line <strong>%d</strong>";
     $severity = $this->determineSeverityTextValue($e->getSeverity());
     $error = $e->getMessage();
     $file = $e->getFile();
     $line = $e->getLine();
     $error = sprintf($errorString, $severity, $error, $file, $line);
     return $this->getTable($error);
 }
示例#6
0
文件: Broker.php 项目: hillstill/sooh
 /**
  * @return \Sooh\DB\Interfaces\All
  */
 public static function getInstance($arrConf_or_Index = null, $modName = null)
 {
     if (is_array($arrConf_or_Index)) {
         $conf = $arrConf_or_Index;
     } else {
         $ini = sooh_ini::getInstance();
         if ($arrConf_or_Index === null) {
             $conf = $ini->get('dbConf');
             if (isset($conf['default'])) {
                 $conf = $conf['default'];
             } elseif (is_array($conf)) {
                 $conf = current($conf);
             } else {
                 throw new \ErrorException('default dbConf not found');
             }
         } else {
             $conf = $ini->get('dbConf.' . $arrConf_or_Index);
         }
     }
     if (!isset($conf['name']) || $modName !== null) {
         if (isset($conf['dbEnums'][$modName])) {
             $conf['name'] = $conf['dbEnums'][$modName];
         } else {
             $conf['name'] = $conf['dbEnums']['default'];
         }
     }
     $id = self::idOfConnection($conf);
     if (empty(self::$_instances[$id])) {
         $type = $conf['type'];
         if (empty($type)) {
             $ttmp = $ini->get('dbConf');
             if (is_array($ttmp)) {
                 $ttmp = implode(',', array_keys($ttmp));
             } else {
                 $ttmp = 'EMPTY';
             }
             $err = new \ErrorException('db-config missing:' . json_encode($arrConf_or_Index) . ' current:' . $ttmp);
             error_log($err->getMessage() . "\n" . $err->getTraceAsString());
             throw $err;
         }
         $class = '\\Sooh\\DB\\Types\\' . ucfirst($type);
         //			if (!class_exists($class, false))
         //				include __DIR__ . '/' . $class . '.php';
         self::$_instances[$id] = new $class($conf);
         self::$_instances[$id]->dbConf = $conf;
         if (sooh_trace::needsWrite(__CLASS__)) {
             sooh_trace::str('create new connection[' . $id . '] of ' . json_encode($conf));
         }
     } else {
         if (sooh_trace::needsWrite(__CLASS__)) {
             sooh_trace::str('exists connection[' . $id . '] of ' . json_encode($conf));
         }
     }
     return self::$_instances[$id];
 }
 public function handleErrors(\ErrorException $e)
 {
     $errorString = "%s%s in %s on line %d\n";
     $severity = $this->determineSeverityTextValue($e->getSeverity());
     // Let's calculate the length of the box, and set the box border.
     $dashes = "\n+" . str_repeat('-', strlen($severity) + 2) . "+\n";
     $severity = $dashes . '| ' . strtoupper($severity) . " |" . $dashes;
     // Okay, now let's prep the message components.
     $error = $e->getMessage();
     $file = $e->getFile();
     $line = $e->getLine();
     $error = sprintf($errorString, $severity, $error, $file, $line);
     return $error;
 }
示例#8
0
 /**
  * @param \Throwable $exception
  */
 public static function exceptionHandler(\Throwable $exception)
 {
     // This error code is not included in error_reporting
     if (!error_reporting() || $exception->getLine() == 0) {
         return;
     }
     $output = new ConsoleOutput(OutputInterface::VERBOSITY_VERY_VERBOSE);
     if (!$exception instanceof \Exception) {
         $exception = new \ErrorException($exception->getMessage(), $exception->getCode(), 0, $exception->getFile(), $exception->getLine(), $exception);
         self::$application->renderException($exception, $output);
     } else {
         self::$application->renderException($exception, $output);
     }
 }
 public static function shutdownCheck()
 {
     //error_log("shutdown check");
     if ($error = error_get_last()) {
         if ($error['type'] == E_COMPILE_ERROR) {
             $exception = new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
             if (strpos($exception->getMessage(), "Cannot redeclare class") !== false) {
                 //send email alerts for duplicate class declarations.. error already logged by php
                 $ErrorHandler = new ErrorHandler($exception);
                 $ErrorHandler->email_alert();
             }
         }
     }
     return;
 }
示例#10
0
文件: Where.php 项目: hillstill/sooh
 public function append($k, $v = null, $ifRealAppend = 'throwError')
 {
     if ($this->dbClass == null) {
         throw new \ErrorException('thisWhere ended already');
     }
     if ($ifRealAppend === false) {
         return $this;
     }
     $bakTb = $this->dbClass->_tmpObj($this->forTable);
     if (empty($v) && is_array($v)) {
         if ($ifRealAppend === 'markEmptyArray') {
             $this->_emptyWhere[] = $k;
             return $this;
         } else {
             $err = new \ErrorException('empty Array was Found when build where');
             error_log($err->getMessage() . "\n" . $err->getTraceAsString());
             throw $err;
         }
     }
     if (is_array($k)) {
         foreach ($k as $i => $v) {
             if (is_numeric($i)) {
                 $this->append(null, $v);
             } else {
                 $this->append($i, $v);
             }
         }
     } elseif (is_null($k)) {
         if (is_scalar($v)) {
             $err = new \ErrorException();
             error_log("should avoid:where->append(null,'sql-statement')\n" . $err->getTraceAsString());
             $this->r[] = $v;
         } else {
             $tmp = trim($v->end());
             if (!empty($tmp)) {
                 $tmp = '(' . substr($tmp, 6) . ')';
             }
             $this->r[] = $tmp;
         }
     } else {
         $this->r[] = $this->conv($k, $v);
     }
     $this->dbClass->_tmpObj($bakTb);
     return $this;
 }
示例#11
0
 public function handleWrite()
 {
     $error = null;
     set_error_handler(function ($errno, $errstr, $errfile, $errline) use(&$error) {
         $error = array('message' => $errstr, 'number' => $errno, 'file' => $errfile, 'line' => $errline);
     });
     $sent = fwrite($this->stream, $this->data);
     restore_error_handler();
     // Only report errors if *nothing* could be sent.
     // Any hard (permanent) error will fail to send any data at all.
     // Sending excessive amounts of data will only flush *some* data and then
     // report a temporary error (EAGAIN) which we do not raise here in order
     // to keep the stream open for further tries to write.
     // Should this turn out to be a permanent error later, it will eventually
     // send *nothing* and we can detect this.
     if ($sent === 0 || $sent === false) {
         if ($error === null) {
             $error = new \RuntimeException('Send failed');
         } else {
             $error = new \ErrorException($error['message'], 0, $error['number'], $error['file'], $error['line']);
         }
         $this->emit('error', array(new \RuntimeException('Unable to write to stream: ' . $error->getMessage(), 0, $error), $this));
         return;
     }
     $exceeded = isset($this->data[$this->softLimit - 1]);
     $this->data = (string) substr($this->data, $sent);
     // buffer has been above limit and is now below limit
     if ($exceeded && !isset($this->data[$this->softLimit - 1])) {
         $this->emit('drain', array($this));
     }
     // buffer is now completely empty (and not closed already)
     if ($this->data === '' && $this->listening) {
         $this->loop->removeWriteStream($this->stream);
         $this->listening = false;
         $this->emit('full-drain', array($this));
     }
 }
示例#12
0
 /**
  * 当调用run()时,如果抛出异常,则调用此方法处理异常(设置最后状态,返回算执行成功还是算执行失败)
  * @param \ErrorException $e
  * @return boolean
  */
 public function onError(\ErrorException $e)
 {
     $this->lastMsg = "[Error]" . $e->getMessage();
     return false;
 }
示例#13
0
文件: Handler.php 项目: dafik/dfi
 public static function shutdown()
 {
     $isError = false;
     if ($error = error_get_last()) {
         switch ($error['type']) {
             case E_ERROR:
                 // 1
             // 1
             case E_CORE_ERROR:
                 // 16
             // 16
             case E_COMPILE_ERROR:
                 // 64
             // 64
             case E_USER_ERROR:
                 //256
             //256
             case E_PARSE:
                 //4
                 $isError = true;
                 break;
             case E_WARNING:
                 //2
             //2
             case E_NOTICE:
                 //8
             //8
             case E_CORE_WARNING:
                 //32
             //32
             case E_COMPILE_WARNING:
                 //128
             //128
             case E_USER_WARNING:
                 //512
             //512
             case E_USER_NOTICE:
                 //1024
             //1024
             case E_STRICT:
                 //2048
                 break;
         }
     }
     if ($isError) {
         http_response_code(500);
         $guid = false;
         try {
             $e = new ErrorException($error['message'], 0, 1, $error['file'], $error['line']);
             //$guid = Dfi_Error_Report::saveException($e);
         } catch (Exception $e) {
             $guid = false;
         }
         if (!preg_match('/cli/', php_sapi_name())) {
             Zend_Registry::get('shutdownLogger')->log($error['message'] . ' : ' . $error['file'] . ' : (' . $error['line'] . ')', Zend_Log::CRIT);
             if (!Dfi_App_Config::get('main.showDebug')) {
                 $url = "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s://" : "://") . $_SERVER['HTTP_HOST'] . '/';
                 header("Location: " . $url . "error/error" . ($guid ? '/guid/' . $guid : ''));
                 exit;
             } else {
                 ob_clean();
                 echo '<pre>REPORT: ' . ($guid ? $guid : 'brak') . "\n";
                 echo 'REQUEST: ' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "\n";
                 echo 'REFERER: ' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . "\n";
                 echo 'ERROR: ' . $e->getMessage() . ' : ' . $e->getFile() . ' : (' . $e->getLine() . ')' . "\n" . $e->getTraceAsString() . '</pre>';
             }
         }
     }
 }
示例#14
0
function error_report(ErrorException $e)
{
    echo 'Message:' . $e->getMessage() . "<br />";
    $trace = $e->getTrace();
}
示例#15
0
 /**
  * @param \ErrorException $e
  * @return array
  */
 public static function createFromPHPError(\ErrorException $e)
 {
     return ['message' => $e->getMessage(), 'severity' => $e->getSeverity(), 'trace' => self::toSafeTrace($e->getTrace())];
 }
 /**
  * {@inheritdoc}
  */
 protected function onNotSuccessfulTest(\Exception $e)
 {
     if (!in_array(get_class($e), array('PHPUnit_Framework_IncompleteTestError', 'PHPUnit_Framework_SkippedTestError'))) {
         $e = new \ErrorException($e->getMessage() . "\nScreenshot: " . $this->makeScreenshot(), $e->getCode(), 0, $e->getFile(), $e->getLine() - 1, $e);
     }
     parent::onNotSuccessfulTest($e);
 }
示例#17
0
 protected function _report_php_error($errno, $errstr, $errfile, $errline)
 {
     if (!$this->check_config()) {
         return;
     }
     if (error_reporting() === 0 && !$this->report_suppressed) {
         // ignore
         return;
     }
     if ($this->use_error_reporting && (error_reporting() & $errno) === 0) {
         // ignore
         return;
     }
     if ($this->included_errno != -1 && ($errno & $this->included_errno) != $errno) {
         // ignore
         return;
     }
     if (isset($this->error_sample_rates[$errno])) {
         // get a float in the range [0, 1)
         // mt_rand() is inclusive, so add 1 to mt_randmax
         $float_rand = mt_rand() / ($this->_mt_randmax + 1);
         if ($float_rand > $this->error_sample_rates[$errno]) {
             // skip
             return;
         }
     }
     $data = $this->build_base_data();
     // set error level and error constant name
     $level = Level::INFO;
     $constant = '#' . $errno;
     switch ($errno) {
         case 1:
             $level = Level::ERROR;
             $constant = 'E_ERROR';
             break;
         case 2:
             $level = Level::WARNING;
             $constant = 'E_WARNING';
             break;
         case 4:
             $level = Level::CRITICAL;
             $constant = 'E_PARSE';
             break;
         case 8:
             $level = Level::INFO;
             $constant = 'E_NOTICE';
             break;
         case 256:
             $level = Level::ERROR;
             $constant = 'E_USER_ERROR';
             break;
         case 512:
             $level = Level::WARNING;
             $constant = 'E_USER_WARNING';
             break;
         case 1024:
             $level = Level::INFO;
             $constant = 'E_USER_NOTICE';
             break;
         case 2048:
             $level = Level::INFO;
             $constant = 'E_STRICT';
             break;
         case 4096:
             $level = Level::ERROR;
             $constant = 'E_RECOVERABLE_ERROR';
             break;
         case 8192:
             $level = Level::INFO;
             $constant = 'E_DEPRECATED';
             break;
         case 16384:
             $level = Level::INFO;
             $constant = 'E_USER_DEPRECATED';
             break;
     }
     $data['level'] = $level;
     // use the whole $errstr. may want to split this by colon for better de-duping.
     $error_class = $constant . ': ' . $errstr;
     // build something that looks like an exception
     $data['body'] = array('trace' => array('frames' => $this->build_error_frames($errfile, $errline), 'exception' => array('class' => $error_class)));
     // request, server, person data
     $data['request'] = $this->build_request_data();
     $data['server'] = $this->build_server_data();
     $data['person'] = $this->build_person_data();
     array_walk_recursive($data, array($this, '_sanitize_utf8'));
     $payload = $this->build_payload($data);
     // Determine whether to send the request to the API.
     $exception = new ErrorException($error_class, 0, $errno, $errfile, $errline);
     if ($this->_shouldIgnore(true, new RollbarException($exception->getMessage(), $exception), $payload)) {
         return;
     }
     $this->send_payload($payload);
     return $data['uuid'];
 }
示例#18
0
 /**
  * Format an \ErrorException into a string destined for PHP error_log()
  *
  * @access private
  * @param \ErrorException $exception The error exception to format
  * @return string The formatted error message
  */
 function formatErrorException($exception)
 {
     if (!$exception instanceof \ErrorException) {
         return '';
     }
     $errorType = '';
     $errorCode = $exception->getCode();
     // Find an error type based on the error code
     switch ($errorCode) {
         case $errorCode & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR):
             $errorType = 'PHP Fatal error';
             break;
         case $errorCode & (E_NOTICE | E_USER_NOTICE):
             $errorType = 'PHP Notice';
             break;
         case $errorCode & (E_WARNING | E_CORE_WARNING | E_COMPILE_WARNING | E_USER_WARNING):
             $errorType = 'PHP Warning';
             break;
         case $errorCode & (E_DEPRECATED | E_USER_DEPRECATED):
             $errorType = 'PHP Deprecated';
             break;
         case $errorCode & E_PARSE:
             $errorType = 'PHP Parse error';
             break;
         case $errorCode & E_STRICT:
             $errorType = 'PHP Strict standards';
             break;
     }
     return formatPHPErrorLog($exception->getMessage(), $errorType, $exception->getFile(), $exception->getLine());
 }
 /**
  * @param \ErrorException $exception
  */
 protected function handleFatalError($exception)
 {
     \Rollbar::report_php_error($exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
     parent::handleException($exception);
 }
示例#20
0
/**
 * Format exception and add session, server and post information for easier debugging.
 *
 * If $full is set to false, only string containing formatted message is returned.
 *
 * @access public
 * @param Exception|ErrorException|mixed $e
 * @param bool $full (default: false)
 * @return string Returns formatted string of the $e exception
 */
function sp_format_exception($e, $full = false)
{
    $session = isset($_SESSION) ? $_SESSION : [];
    $post = $_POST;
    $message = str_replace("\n", "<br />", $e->getMessage());
    $message .= '<br /><br /><strong>Trace:</strong><br /><table border="0" cellspacing="0" cellpadding="5" style="border: 1px #DADADA solid;"><tr><td style="border-bottom: 1px #DADADA solid;">';
    $message .= str_replace("\n", '</td></tr><tr><td style="border-bottom: 1px #DADADA solid;">', $e->getTraceAsString()) . '</td></tr></table>';
    $session = str_replace(array(" ", "\n"), array('&nbsp;', '<br />'), json_encode($session, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null));
    $server = str_replace(array(" ", "\n"), array('&nbsp;', '<br />'), json_encode($_SERVER, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null));
    $post = str_replace(array(" ", "\n"), array('&nbsp;', '<br />'), json_encode($post, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null));
    if (!empty($full)) {
        return "<strong>Error:</strong><br />{$message}<br /><br /><strong>Sesssion Info:</strong><br />{$session}<br /><br /><strong>Post Info:</strong><br />{$post}<br /><br /><strong>Server:</strong><br />{$server}";
    } else {
        return "<pre><strong>Error:</strong><br />{$message}<br /></pre>";
    }
}
示例#21
0
 public function handleData($stream)
 {
     $error = null;
     set_error_handler(function ($errno, $errstr, $errfile, $errline) use(&$error) {
         $error = new \ErrorException($errstr, 0, $errno, $errfile, $errline);
     });
     $data = fread($stream, $this->bufferSize);
     restore_error_handler();
     if ($error !== null) {
         $this->emit('error', array(new \RuntimeException('Unable to read from stream: ' . $error->getMessage(), 0, $error), $this));
         $this->close();
         return;
     }
     if ($data !== '') {
         $this->emit('data', array($data, $this));
     }
     if (!is_resource($stream) || feof($stream)) {
         $this->end();
     }
 }
示例#22
0
 protected function _query($sql)
 {
     if ($sql == null) {
         if (empty($this->_lastCmd)) {
             throw new \ErrorException('empty sql given');
         }
         $orderby = array();
         $groupby = array();
         if (!empty($this->_lastCmd->orderby)) {
             $arr = explode(' ', trim($this->_lastCmd->orderby));
             $mx = count($arr);
             for ($i = 0; $i < $mx; $i += 2) {
                 $k = $arr[$i];
                 $v = $arr[$i + 1];
                 switch ($k) {
                     case 'rsort':
                         $orderby[] = $v . ' desc';
                         break;
                     case 'sort':
                         $orderby[] = $v;
                         break;
                     case 'groupby':
                     case 'group':
                         $groupby[] = $v;
                         break;
                     default:
                         $err = new \ErrorException('unsupport:' . $orderby);
                         sooh_trace::exception($err);
                         throw $err;
                 }
             }
         }
         $this->_lastCmd->dowhat = strtolower($this->_lastCmd->dowhat);
         switch ($this->_lastCmd->dowhat) {
             case 'select':
                 $sql = 'select ';
                 if (is_array($this->_lastCmd->fromAndSize) && $this->_lastCmd->fromAndSize[1] > 0) {
                     $sql .= ' top ' . $this->_lastCmd->fromAndSize[1] . ' ';
                     if ($this->_lastCmd->fromAndSize[0] !== 0) {
                         if (is_array($this->_lastCmd->pkey) && sizeof($this->_lastCmd->pkey) > 1) {
                             throw new \ErrorException("multi-pkey not support in mssql for limit");
                         }
                         if (is_array($this->_lastCmd->pkey)) {
                             $pkey = key($this->_lastCmd->pkey);
                             if (is_int($pkey)) {
                                 $pkey = current($this->_lastCmd->pkey);
                             }
                         } else {
                             if (empty($this->_lastCmd->pkey)) {
                                 $pkey = 'Id';
                             } else {
                                 if (is_string($this->_lastCmd->pkey)) {
                                     $pkey = $this->_lastCmd->pkey;
                                 } else {
                                     throw new \ErrorException("invalid pkey  in mssql found for limit");
                                 }
                             }
                         }
                         $limit = "{$pkey} NOT IN (SELECT TOP {$this->_lastCmd->fromAndSize[0]} {$pkey} FROM {$this->_lastCmd->tablenamefull} __WHERE__";
                         if (!empty($orderby)) {
                             $limit .= ' order by ' . implode(',', $orderby);
                         }
                         $limit .= ")";
                         //throw new \ErrorException('todo: 获取并缓存主键');//SELECT TOP 10 * FROM sql WHERE ( code NOT IN (SELECT TOP 20 code FROM TestTable ORDER BY id))
                     }
                 }
                 $sql .= $this->_fmtField($this->_lastCmd->field) . ' from ' . $this->_lastCmd->tablenamefull;
                 break;
             case 'addlog':
             case 'insert':
                 $sql = 'insert into ' . $this->_lastCmd->tablenamefull;
                 $sql .= " (" . implode(',', array_keys($this->_lastCmd->field)) . ") ";
                 $sql .= "values (";
                 foreach ($this->_lastCmd->field as $k => $v) {
                     $sql .= $this->_safe($k, $v) . ',';
                 }
                 $sql = substr($sql, 0, -1) . ")";
                 break;
             case 'update':
                 //update FE_temp.dbo.tb_user set tb_user.timeLastBought = tb_bought.lastBought
                 ////	from FE_temp.dbo.tb_user left join FE_temp.dbo.tb_bought on tb_bought.userIdentifier=tb_user.userIdentifier
                 $sql = 'update ' . $this->_lastCmd->tablenamefull . ' set ' . $this->_fmtField($this->_lastCmd->field);
                 break;
             case 'delete':
                 $sql = 'delete from ' . $this->_lastCmd->tablenamefull;
                 break;
             default:
                 throw new \ErrorException('unsupport sql cmd:' . $this->_lastCmd->dowhat);
         }
         if (!empty($limit)) {
             if (!empty($this->_lastCmd->where)) {
                 $where = substr(trim($this->_lastCmd->where), 5);
                 $limit = str_replace('__WHERE__', ' where ' . $where, $limit);
                 $sql .= ' where (' . $where . ') and (' . $limit . ')';
             } else {
                 $sql .= ' where ' . ($limit = str_replace('__WHERE__', '', $limit));
             }
         } elseif (!empty($this->_lastCmd->where)) {
             $sql .= ' ' . $this->_lastCmd->where;
         }
         if (!empty($this->_lastCmd->orderby)) {
             if (!empty($groupby)) {
                 $sort_group .= ' group by ' . implode(',', $groupby);
             }
             if (!empty($orderby)) {
                 $sort_group .= ' order by ' . implode(',', $orderby);
             }
             $sql .= ' ' . $sort_group;
         }
         $this->_lastCmd->resetForNext();
         $this->_lastCmd->strTrace = '[' . $this->_lastCmd->server . ']' . $sql;
     } else {
         if (is_string($sql)) {
             $this->_lastCmd->resetForNext();
             $this->_lastCmd->strTrace = '[' . $this->_lastCmd->server . ']' . $sql;
         } else {
             $err = new \ErrorException('sql gived is not a string');
             error_log($err->getMessage() . "\n" . $err->getTraceAsString());
             throw $err;
         }
     }
     sooh_broker::pushCmd($this->_lastCmd);
     $skip = sooh_dbErr::$maskSkipTheseError;
     sooh_dbErr::$maskSkipTheseError = array();
     //throw new \ErrorException($sql);
     $rs = sqlsrv_query($this->_connection, $sql);
     $this->_chkErr($skip);
     return $rs;
 }
示例#23
0
 /**
  * 获取某个字段的值
  * @param string $field 字段名
  * @param boolean $nullAccepted 当取得的值是null的时候,是否应该丢出异常
  */
 public function getField($field, $nullAccepted = false)
 {
     if (!isset($this->r[$field])) {
         if ($nullAccepted == false) {
             $err = new \ErrorException("fieldGet of {$field} not loaded or is NULL \nwhen request:" . $_SERVER["REQUEST_URI"] . "\n check code of load(cur loaded:" . (is_array($this->r) ? implode(',', array_keys($this->r)) : "NULL") . ")\npkey=" . json_encode($this->pkey));
             error_log($err->getMessage() . "\n" . $err->getTraceAsString());
             throw $err;
         } else {
             return null;
         }
     }
     return $this->r[$field];
 }
示例#24
0
 /**
  * Log error exceptions to user console using JSON_Response::error
  *
  * @param ErrorException $err_exc The error exception
  * @return void
  * @uses JSON_Response
  */
 public function consoleErrorException(\ErrorException $err_exc)
 {
     Core\JSON_Response::load()->error(['message' => $err_exc->getMessage(), 'code' => $err_exc->getCode(), 'severity' => $err_exc->getSeverity(), 'line' => $err_exc->getLine(), 'file' => $err_exc->getFile(), 'trace' => $err_exc->getTrace()]);
 }
示例#25
0
文件: Task.php 项目: hillstill/sooh
 /**
  * 当调用run()时,如果抛出异常,则调用此方法处理异常(设置最后状态,返回算执行成功还是算执行失败)
  * @param \ErrorException $e
  * @return boolean
  */
 public function onError(\ErrorException $e)
 {
     $this->lastMsg = "[Error]" . $e->getMessage();
     error_log("Error_Crond_Task:" . get_called_class() . "#" . $e->getMessage() . "\n" . $e->getTraceAsString());
     return false;
 }