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);
 }
Exemple #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;
 }
Exemple #3
0
 static function handle($code, $message, $file, $line, $context)
 {
     echo "\n" . static::$codeMap[$code] . ': ' . $message . "\n";
     echo "#0 " . $file . '(' . $line . ")\n";
     $exception = new ErrorException('', $code, 0, $file, $line);
     $trace = $exception->getTraceAsString();
     $trace = preg_replace('~^.*?\\n|\\n.*?$~', '', $trace);
     echo $trace . "\n";
     return true;
 }
Exemple #4
0
 /**
  * @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];
 }
Exemple #5
0
 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;
 }
Exemple #6
0
 /**
  * Store Error exceptions to database from prepared statement
  *
  * @param ErrorException $err_exc The error exception
  * @return void
  */
 public function DBErrorException(\ErrorException $err_exc)
 {
     if (!$this->error_stm instanceof API\Interfaces\PDOStatement) {
         $this->registerPDOStatement();
     }
     $this->error_stm->{$this->binders['message']} = $err_exc->getMessage();
     $this->error_stm->{$this->binders['code']} = $err_exc->getCode();
     $this->error_stm->{$this->binders['severity']} = $err_exc->getSeverity();
     $this->error_stm->{$this->binders['file']} = $err_exc->getFile();
     $this->error_stm->{$this->binders['line']} = $err_exc->getLine();
     $this->error_stm->{$this->binders['trace']} = $err_exc->getTraceAsString();
     $this->error_stm->execute();
 }
Exemple #7
0
 /**
  * Scalr error handler
  *
  * @param   int        $errno
  * @param   string     $errstr
  * @param   string     $errfile
  * @param   int        $errline
  * @throws  \Exception
  */
 public static function errorHandler($errno, $errstr, $errfile, $errline)
 {
     // Handles error suppression.
     if (0 === error_reporting()) {
         return false;
     }
     //Friendly error name
     switch ($errno) {
         case E_NOTICE:
             $errname = 'E_NOTICE';
             break;
         case E_WARNING:
             $errname = 'E_WARNING';
             break;
         case E_USER_DEPRECATED:
             $errname = 'E_USER_DEPRECATED';
             break;
         case E_STRICT:
             $errname = 'E_STRICT';
             break;
         case E_USER_NOTICE:
             $errname = 'E_USER_NOTICE';
             break;
         case E_USER_WARNING:
             $errname = 'E_USER_WARNING';
             break;
         case E_COMPILE_ERROR:
             $errname = 'E_COMPILE_ERROR';
             break;
         case E_COMPILE_WARNING:
             $errname = 'E_COMPILE_WARNING';
             break;
         case E_CORE_ERROR:
             $errname = 'E_CORE_ERROR';
             break;
         case E_CORE_WARNING:
             $errname = 'E_CORE_WARNING';
             break;
         case E_DEPRECATED:
             $errname = 'E_DEPRECATED';
             break;
         case E_ERROR:
             $errname = 'E_ERROR';
             break;
         case E_PARSE:
             $errname = 'E_PARSE';
             break;
         case E_RECOVERABLE_ERROR:
             $errname = 'E_RECOVERABLE_ERROR';
             break;
         case E_USER_ERROR:
             $errname = 'E_USER_ERROR';
             break;
         default:
             $errname = $errno;
     }
     $message = "Error {$errname} {$errstr}, in {$errfile}:{$errline}\n";
     switch ($errno) {
         case E_USER_NOTICE:
         case E_NOTICE:
             //Ignore for a while.
             break;
         case E_CORE_ERROR:
         case E_ERROR:
         case E_USER_ERROR:
         case E_RECOVERABLE_ERROR:
             $exception = new \ErrorException($errname, $errno, 0, $errfile, $errline);
             $message = $message . "Stack trace:\n " . str_replace("\n#", "\n  #", $exception->getTraceAsString());
             @error_log($message);
             throw $exception;
             break;
         case E_WARNING:
         case E_USER_WARNING:
             $exception = new \ErrorException($errname, $errno, 0, $errfile, $errline);
             $message = $message . "Stack trace:\n  " . str_replace("\n#", "\n  #", $exception->getTraceAsString());
         default:
             @error_log($message);
             break;
     }
 }
Exemple #8
0
 *
 * MPF Framework is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MPF Framework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MPF Framework.  If not, see <http://www.gnu.org/licenses/>.
 */
define('LIBS_FOLDER', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR);
define('APP_ROOT', __DIR__ . DIRECTORY_SEPARATOR);
/**
 * Set ErrorException for every error;
 */
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
    $severity = 1 * E_ERROR | 1 * E_WARNING | 1 * E_PARSE | 1 * E_NOTICE | 0 * E_CORE_ERROR | 0 * E_CORE_WARNING | 0 * E_COMPILE_ERROR | 0 * E_COMPILE_WARNING | 1 * E_USER_ERROR | 1 * E_USER_WARNING | 1 * E_USER_NOTICE | 0 * E_STRICT | 0 * E_RECOVERABLE_ERROR | 0 * E_DEPRECATED | 0 * E_USER_DEPRECATED;
    $ex = new \ErrorException($errstr, 0, $errno, $errfile, $errline);
    if (($ex->getSeverity() & $severity) != 0) {
        \mpf\ConsoleApp::get()->error($errstr, array('File' => $errfile, 'Line' => $errline, 'Number' => $errno, 'Trace' => $ex->getTraceAsString()));
    }
});
$autoload = (require_once LIBS_FOLDER . 'autoload.php');
use mpf\ConsoleApp as App;
use mpf\base\Config;
new Config(APP_ROOT . 'config' . DIRECTORY_SEPARATOR . 'console.inc.php');
App::run(array('startTime' => microtime(true), 'autoload' => $autoload));
Exemple #9
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];
 }
 public function handleError($severity, $message, $filename, $lineno)
 {
     if (error_reporting() == 0) {
         return;
     }
     if (error_reporting() & $severity) {
         $exception = new ErrorException($message, 0, $severity, $filename, $lineno);
         Gpf_Log::warning('Error calling function: ' . $this->getFunctionName($this->callback) . ', with parameters: ' . var_export($this->params, true) . '. Error trace: ' . $exception->getTraceAsString());
         if ($severity != E_WARNING && $severity != E_NOTICE) {
             throw $exception;
         }
     }
 }
 /**
  * Error handler.
  *
  * Handle errors like PHP does it natively but additionally log them to the
  * application error log file.
  *
  * @param int    $intType    The type of the error.
  *
  * @param string $strMessage The error message.
  *
  * @param string $strFile    The file where the error originated from.
  *
  * @param int    $intLine    The line on which the error was raised.
  *
  * @return void
  */
 public static function errorHandler($intType, $strMessage, $strFile, $intLine)
 {
     if ($intType === E_NOTICE && (strpos($strFile, 'system/modules/core') !== false || strpos($strFile, 'system/helper/functions.php') !== false)) {
         return;
     }
     if ($intType != E_WARNING && strpos($strMessage, 'sort(): Array was modified by the user comparison function') !== false) {
         // @codingStandardsIgnoreStart
         // See:
         //   http://stackoverflow.com/questions/3235387/usort-array-was-modified-by-the-user-comparison-function
         //   https://bugs.php.net/bug.php?id=50688
         //   http://wpdailydose.com/discoveries/array-modified/
         // @codingStandardsIgnoreEnd
         return;
     }
     $exception = new \ErrorException(self::getErrorName($intType) . ': ' . $strMessage, 0, $intType, $strFile, $intLine);
     if ($intType !== E_NOTICE) {
         // Log the error.
         error_log(sprintf("\nPHP %s: %s in %s on line %s\n%s\n", self::getErrorName($intType), $strMessage, $strFile, $intLine, $exception->getTraceAsString()));
     }
     self::addException($exception);
     // Exit on severe errors.
     if ($intType & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR)) {
         // Help message will get shown by debugger post mortem.
         exit;
     }
 }
Exemple #12
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>";
    }
}
Exemple #13
0
            try {
                TestHelpers::purge($dir);
            } catch (Exception $e) {
            }
            @rmdir($dir);
        }
    }
}
// create temporary directory
define('TEMP_DIR', __DIR__ . '/../tmp/' . getmypid());
TestHelpers::purge(TEMP_DIR);
// catch unexpected errors/warnings/notices
set_error_handler(function ($severity, $message, $file, $line) {
    if (($severity & error_reporting()) === $severity) {
        $e = new ErrorException($message, 0, $severity, $file, $line);
        echo "Error: {$message} in {$file}:{$line}\nStack trace:\n" . $e->getTraceAsString();
        exit(TestCase::CODE_ERROR);
    }
    return FALSE;
});
$_SERVER = array_intersect_key($_SERVER, array_flip(array('PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS')));
$_SERVER['REQUEST_TIME'] = 1234567890;
$_ENV = $_GET = $_POST = array();
if (PHP_SAPI !== 'cli') {
    header('Content-Type: text/plain; charset=utf-8');
}
if (extension_loaded('xdebug')) {
    xdebug_disable();
    TestHelpers::startCodeCoverage(__DIR__ . '/coverage.dat');
}
function id($val)
Exemple #14
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;
 }
Exemple #15
0
 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>';
             }
         }
     }
 }
Exemple #16
0
 /**
  * 当调用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;
 }