本文整理汇总了PHP中ErrorException::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorException::getMessage方法的具体用法?PHP ErrorException::getMessage怎么用?PHP ErrorException::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorException
的用法示例。
在下文中一共展示了ErrorException::getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleErrorException
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;
}
示例2: handleErrorException
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);
}
示例3: handleErrors
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: handleErrors
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: handleErrors
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: getInstance
/**
* @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];
}
示例7: handleErrors
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: exceptionHandler
/**
* @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);
}
}
示例9: shutdownCheck
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: append
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: handleWrite
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: onError
/**
* 当调用run()时,如果抛出异常,则调用此方法处理异常(设置最后状态,返回算执行成功还是算执行失败)
* @param \ErrorException $e
* @return boolean
*/
public function onError(\ErrorException $e)
{
$this->lastMsg = "[Error]" . $e->getMessage();
return false;
}
示例13: shutdown
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: error_report
function error_report(ErrorException $e)
{
echo 'Message:' . $e->getMessage() . "<br />";
$trace = $e->getTrace();
}
示例15: createFromPHPError
/**
* @param \ErrorException $e
* @return array
*/
public static function createFromPHPError(\ErrorException $e)
{
return ['message' => $e->getMessage(), 'severity' => $e->getSeverity(), 'trace' => self::toSafeTrace($e->getTrace())];
}