本文整理汇总了PHP中ErrorException::getSeverity方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorException::getSeverity方法的具体用法?PHP ErrorException::getSeverity怎么用?PHP ErrorException::getSeverity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorException
的用法示例。
在下文中一共展示了ErrorException::getSeverity方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleErrorException
/**
* @param \ErrorException $exception
*
* @return bool
*/
protected function handleErrorException(\ErrorException $exception)
{
switch ($exception->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($this->buildLogMessage($exception));
break;
case E_WARNING:
case E_USER_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
$this->logger->warning($this->buildLogMessage($exception));
break;
case E_NOTICE:
case E_USER_NOTICE:
$this->logger->notice($this->buildLogMessage($exception));
break;
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
$this->logger->info($this->buildLogMessage($exception));
break;
}
return true;
}
示例2: 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);
}
示例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)
{
$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);
}
示例5: 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;
}
示例6: test
public function test()
{
$exception = new ErrorException(E_NOTICE, 'message', 'file', 0, 1);
$this->assertSame(E_NOTICE, $exception->getSeverity());
$this->assertSame('message', $exception->getMessage());
$this->assertSame('Notice', $exception->getSeverityAsString());
$this->assertSame('E_NOTICE', $exception->getSeverityAsConstantName());
$this->assertSame('file', $exception->getFile());
$this->assertSame(0, $exception->getLine());
$sourceTrace = array_slice($exception->getTrace(), 1);
$this->assertSame($sourceTrace, $exception->getSourceTrace());
$this->assertSame(StackTraceFormatter::format($exception->getSourceTrace()), $exception->getSourceTraceAsString());
$this->assertSame('exception \'Hyperframework\\Common\\ErrorException\' ' . "with message 'message' in file:0" . PHP_EOL . 'Stack trace:' . PHP_EOL . $exception->getSourceTraceAsString(), (string) $exception);
}
示例7: getSeverity
/**
* Helper for getting an output style for the given ErrorException's level.
*
* @param \ErrorException $e
*
* @return string
*/
protected function getSeverity(\ErrorException $e)
{
$severity = $e->getSeverity();
if ($severity & error_reporting()) {
switch ($severity) {
case E_WARNING:
case E_NOTICE:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
case E_USER_NOTICE:
case E_STRICT:
return 'warning';
default:
return 'error';
}
} else {
// Since this is below the user's reporting threshold, it's always going to be a warning.
return 'warning';
}
}
示例8: Config
* 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);
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) {
throw $ex;
}
});
require_once LIBS_FOLDER . 'mpf' . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . 'AutoLoader.php';
mpf\base\AutoLoader::get()->register();
use mpf\WebApp as App;
use mpf\base\Config;
new Config(__DIR__ . DIRECTORY_SEPARATOR . 'config/web.inc.php');
\mpf\base\AutoLoader::get()->applyConfig(Config::get()->forClass('\\mpf\\base\\AutoLoader'));
App::run(array('requestClass' => '\\mpf\\web\\request\\SOAP'));
示例9: __construct
public function __construct($message, \ErrorException $previous)
{
parent::__construct($message, $previous->getCode(), $previous->getSeverity(), $previous->getFile(), $previous->getLine(), $previous->getPrevious());
$this->setTrace($previous->getTrace());
}
示例10: logError
/**
* Log an exception that wasn't thrown but made to wrap an error.
*
* @since 1.25
* @param ErrorException $e
* @param string $channel
*/
protected static function logError(ErrorException $e, $channel)
{
global $wgLogExceptionBacktrace;
// The set_error_handler callback is independent from error_reporting.
// Filter out unwanted errors manually (e.g. when MediaWiki\suppressWarnings is active).
$suppressed = (error_reporting() & $e->getSeverity()) === 0;
if (!$suppressed) {
$log = self::getLogMessage($e);
if ($wgLogExceptionBacktrace) {
wfDebugLog($channel, $log . "\n" . $e->getTraceAsString());
} else {
wfDebugLog($channel, $log);
}
}
// Include all errors in the json log (surpressed errors will be flagged)
$json = self::jsonSerializeException($e, false, FormatJson::ALL_OK);
if ($json !== false) {
wfDebugLog("{$channel}-json", $json, 'private');
}
Hooks::run('LogException', array($e, $suppressed));
}
示例11: logError
/**
* Log an exception that wasn't thrown but made to wrap an error.
*
* @since 1.25
* @param ErrorException $e
* @param string $channel
*/
protected static function logError(ErrorException $e, $channel)
{
// The set_error_handler callback is independent from error_reporting.
// Filter out unwanted errors manually (e.g. when
// MediaWiki\suppressWarnings is active).
$suppressed = (error_reporting() & $e->getSeverity()) === 0;
if (!$suppressed) {
$logger = LoggerFactory::getInstance($channel);
$logger->error(self::getLogMessage($e), self::getLogContext($e));
}
// Include all errors in the json log (surpressed errors will be flagged)
$json = self::jsonSerializeException($e, false, FormatJson::ALL_OK);
if ($json !== false) {
$logger = LoggerFactory::getInstance("{$channel}-json");
$logger->error($json, ['private' => true]);
}
Hooks::run('LogException', [$e, $suppressed]);
}
示例12: consoleErrorException
/**
* 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()]);
}
示例13: createFromPHPError
/**
* @param \ErrorException $e
* @return array
*/
public static function createFromPHPError(\ErrorException $e)
{
return ['message' => $e->getMessage(), 'severity' => $e->getSeverity(), 'trace' => self::toSafeTrace($e->getTrace())];
}