本文整理汇总了PHP中Exception::getSeverity方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getSeverity方法的具体用法?PHP Exception::getSeverity怎么用?PHP Exception::getSeverity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getSeverity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log
protected function log(\Exception $e, $contextInfo = NULL)
{
if ($e instanceof \ErrorException) {
$errorType = self::$errors[$e->getSeverity()];
} else {
$errorType = Code::getClass($e);
}
// wir müssen hier den error selbst loggen, da php nichts mehr macht (die faule banane)
$php = NULL;
$php .= 'PHP ' . $errorType . ': ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
$php .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
error_log($php, 0);
/* Debug-Mail */
$debug = NULL;
$debug .= '[' . date('d.M.Y H:i:s') . "] ";
$debug .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
if ($e instanceof \Psc\Code\ErrorException) {
$debug .= "\n" . $e->contextDump;
}
if (isset($contextInfo)) {
$debug .= "\nContextInfo: \n" . $contextInfo;
}
if (isset($this->recipient) && !PSC::inTests()) {
if ($ret = @mail($this->recipient, '[Psc-ErrorHandler] [' . $e->getCode() . '] ' . $e->getMessage(), $debug, 'From: www@' . PSC::getEnvironment()->getHostName() . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n") === FALSE) {
error_log('[\\Psc\\Code\\ErrorHandler.php:' . __LINE__ . '] Die Fehlerinformationen konnten nicht an den lokalen Mailer übergeben werden.', 0);
}
}
}
示例2: getMessage
private function getMessage(\Exception $exception)
{
if ($exception instanceof \ErrorException) {
return ErrorHandler::getErrNoString($exception->getSeverity()) . ' - ' . $exception->getMessage();
}
return $exception->getMessage();
}
示例3: createError
/**
* Creates an error from an exception.
*
* @param \Exception $exception
*
* @return Error
*/
public function createError(\Exception $exception)
{
$severity = E_RECOVERABLE_ERROR;
if ($exception instanceof \ErrorException) {
$severity = $exception->getSeverity();
}
return new Error($exception->getMessage(), $severity, get_class($exception), $this->createTrace($exception));
}
示例4: handle
/**
* Tries to handle the exception.
*
* @param Exception $e
* @return true
*/
function handle(Exception $e)
{
if (!$e instanceof ErrorException || $e->getSeverity() & $this->level) {
echo '<pre>', $e, '</pre>';
$this->doExit();
}
return false;
}
示例5: handle
/**
* Tries to handle the exception.
*
* @param Exception $e
* @return true
*/
function handle(Exception $e)
{
if (!$e instanceof ErrorException || $e->getSeverity() & $this->level) {
fwrite(STDERR, $e->__toString());
$this->doExit($e->getCode());
}
return false;
}
示例6: logException
/**
* Shorthand: Logs the given Exception.
*
* @param Exception $exception The Exception to log
*/
public static function logException(Exception $exception)
{
if ($exception instanceof ErrorException) {
self::logError($exception->getSeverity(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
} else {
$logger = self::factory();
$logger->log(get_class($exception), $exception->getMessage(), [], $exception->getFile(), $exception->getLine());
}
}
示例7: render
/**
* Renders blue screen.
* @param \Exception
* @return void
*/
public function render(\Exception $exception)
{
$panels = $this->panels;
$info = array_filter($this->info);
$source = Helpers::getSource();
$sourceIsUrl = preg_match('#^https?://#', $source);
$title = $exception instanceof \ErrorException ? Helpers::errorTypeToString($exception->getSeverity()) : get_class($exception);
$skipError = $sourceIsUrl && $exception instanceof \ErrorException && !empty($exception->skippable) ? $source . (strpos($source, '?') ? '&' : '?') . '_tracy_skip_error' : NULL;
require __DIR__ . '/templates/bluescreen.phtml';
}
示例8: ignoreError
/**
*
*
* @param Exception $e
*
* @return
*/
protected function ignoreError(Exception $e)
{
$code = $e->getCode();
if (empty($code) && $e instanceof ErrorException) {
$code = $e->getSeverity();
}
if (in_array($code, $this->options['ignore_errors'])) {
$this->logIgnored($e);
return true;
}
return false;
}
示例9: handleException
/**
* @param Exception $exception
*/
public function handleException(Exception $exception)
{
$printException = true;
if ($exception instanceof CM_Exception) {
$printException = $exception->getSeverity() >= $this->_getPrintSeverityMin();
}
try {
$this->logException($exception);
} catch (Exception $e) {
$printException = true;
}
if ($printException) {
$this->_printException($exception);
}
if (!$exception instanceof CM_Exception || $exception->getSeverity() >= CM_Exception::ERROR) {
CM_Service_Manager::getInstance()->getNewrelic()->setNoticeError($exception);
}
}
示例10: getTrace
/**
* Gets the backgrace from an exception.
*
* If xdebug is installed
*
* @param Exception $e
* @return array
*/
protected function getTrace(\Exception $e)
{
$traces = $e->getTrace();
// Get trace from xdebug if enabled, failure exceptions only trace to the shutdown handler by default
if (!$e instanceof \ErrorException) {
return $traces;
}
if (!Misc::isLevelFatal($e->getSeverity())) {
return $traces;
}
if (!extension_loaded('xdebug') || !xdebug_is_enabled()) {
return array();
}
// Use xdebug to get the full stack trace and remove the shutdown handler stack trace
$stack = array_reverse(xdebug_get_function_stack());
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$traces = array_diff_key($stack, $trace);
return $traces;
}
示例11: render
/**
* The render function will take an Exception and output a HTML page
*
* @param Exception $e
* The Exception object
* @return string
* An HTML string
*/
public static function render(Exception $e)
{
$lines = null;
foreach (self::__nearByLines($e->getLine(), $e->getFile()) as $line => $string) {
$lines .= sprintf('<li%s><strong>%d</strong> <code>%s</code></li>', $line + 1 == $e->getLine() ? ' class="error"' : null, ++$line, str_replace("\t", ' ', htmlspecialchars($string)));
}
$trace = null;
foreach ($e->getTrace() as $t) {
$trace .= sprintf('<li><code><em>[%s:%d]</em></code></li><li><code>    %s%s%s();</code></li>', isset($t['file']) ? $t['file'] : null, isset($t['line']) ? $t['line'] : null, isset($t['class']) ? $t['class'] : null, isset($t['type']) ? $t['type'] : null, $t['function']);
}
$queries = null;
if (is_object(Symphony::Database())) {
$debug = Symphony::Database()->debug();
if (!empty($debug)) {
foreach ($debug as $query) {
$queries .= sprintf('<li><em>[%01.4f]</em><code> %s;</code> </li>', isset($query['execution_time']) ? $query['execution_time'] : null, htmlspecialchars($query['query']));
}
}
}
return self::renderHtml('fatalerror.generic', $e instanceof ErrorException ? GenericErrorHandler::$errorTypeStrings[$e->getSeverity()] : 'Fatal Error', $e->getMessage(), $e->getFile(), $e->getLine(), $lines, $trace, $queries);
}
示例12: addError
/**
* Log exception
*
* @param \Exception $exception
* @return \Consumerr\Entities\Error
*/
public static function addError(\Exception $exception)
{
if ($exception instanceof \ErrorException && self::$configuration->isErrorDisabled($exception->getSeverity())) {
self::log("Error handler - severity {$exception->getSeverity()} is ignored by current disabled-severity setting.");
return NULL;
}
$error = new Entities\Error($exception);
self::getAccess()->addError($error);
self::log("Added error - '" . get_class($exception) . " - " . $exception->getMessage() . "'");
return $error;
}
示例13: dumpException
public static function dumpException(\Exception $exception, $stream = STDERR)
{
if ($exception instanceof \ErrorException) {
$title = 'Fatal error (' . ErrorHandler::toString($exception->getSeverity()) . ')';
} else {
$title = get_class($exception);
}
fwrite($stream, $title . ': ' . $exception->getMessage() . ' in ' . $exception->getFile() . ':' . $exception->getLine() . PHP_EOL . PHP_EOL);
fwrite($stream, 'Stack trace:' . PHP_EOL);
$trace = $exception->getTrace();
foreach ($trace as $i => $call) {
$message = ' ' . sprintf('% 2d', $i) . '. ';
if (isset($call['file'])) {
$message .= $call['file'] . ':';
$message .= $call['line'] . ' ';
}
if (isset($call['class'])) {
$message .= $call['class'] . '::';
}
$message .= $call['function'] . '(';
$arglist = array();
if (isset($call['args'])) {
foreach ($call['args'] as $arg) {
$arglist[] = is_scalar($arg) ? var_export($arg, true) : gettype($arg);
}
$message .= implode(', ', $arglist);
}
$message .= ')' . PHP_EOL;
fwrite($stream, $message);
}
$previous = $exception->getPrevious();
if (isset($previous)) {
fwrite($stream, 'Caused by:' . PHP_EOL);
self::dumpException($previous);
}
fflush($stream);
}
示例14: crashReport
/**
* Output an HTML crash report based on an exception. Can use a custom
* template stored in 'app/templates/error/exception.php'.
* @param \Exception $exception \Exception to report.
*/
public function crashReport($exception)
{
$app = $this->name;
$version = $this->version;
if ($exception instanceof \ErrorException) {
$title = tr('Fatal error (%1)', ErrorHandler::toString($exception->getSeverity()));
} else {
$title = tr('Uncaught exception');
}
$log = array();
if ($this->logger instanceof \Jivoo\Core\Log\Logger) {
$log = $this->logger->getLog();
}
$custom = null;
try {
if (isset($this->errorPaths['exceptionTemplate'])) {
include $this->errorPaths['exceptionTemplate'];
$custom = true;
}
} catch (\Exception $e) {
$this->logger->alert(tr('Exception template (%1) failed: %2', '{template}', $e->getMessage()), array('template' => $this->errorPaths['exceptionTemplate'], 'exception' => $e));
}
if (!isset($custom)) {
include \Jivoo\PATH . '/Core/templates/error/exception.php';
}
}
示例15: catchException
/**
* Catches an exception. Non-fatal and fatal exceptions are handled
* differently:
* - fatal: Re-thrown so they abort the current request. Fatal
* exceptions are later passed on to catchFinalException().
* - non-fatal: Processed using aggregateException(). Additionally
* they are logged by calling api_exceptionhandler::log().
*
* Exceptions of type api_exceptions (and subclasses) have a getSeverity()
* method which indicates if the exception is fatal. All other exceptions
* are assumed to always be fatal.
*
* @param $e api_exception: Thrown exception.
* @param $prms array: Parameters to give more context to the exception.
*/
private function catchException(Exception $e, $prms = array())
{
if ($e instanceof api_exception && $e->getSeverity() === api_exception::THROW_NONE) {
$this->aggregateException($e, $prms);
api_exceptionhandler::log($e);
} else {
throw $e;
}
}