/**
  * Tests whether severityIsError() works as expected.
  *
  * @dataProvider dataProviderTestSeverityType
  */
 public function testSeverityIsError($severity, $isNotice, $isWarning, $isError, $severityType)
 {
     $this->assertSame($isError, ExceptionUtil::severityIsError($severity));
 }
示例#2
0
 /**
  * Handles uncaught exceptions.
  *
  * The cast to integer for the exception code is necessary, because there
  * are exceptions with a non-numeric exception code (e.g. PDOException has
  * something like "HY000".
  *
  * @param \Throwable $t The uncaught exception. Can be either {@link \Exception} or {@link \Error} as of PHP 7, thus needs to be \Throwable
  * @return void
  */
 public static final function handleException(Throwable $t)
 {
     // convert given throwable into internal exception if necessary
     $exception = $t instanceof SystemException ? $t : new SystemException($t->getMessage(), (int) $t->getCode(), E_USER_ERROR, $t->getFile(), $t->getLine(), $t->getPrevious());
     // log exception
     self::getLogManager()->logException('Uncaught exception', $exception);
     // stop script execution on fatal errors
     if (ExceptionUtil::severityIsError($exception->getSeverity())) {
         self::exitWithInternalServerError();
     }
 }