decodeException example

// Persist any special HTTP headers that were set on the exception.       if ($exception instanceof HttpExceptionInterface) {
        $response->headers->add($exception->getHeaders());
      }

      $event->setResponse($response);
    }
    catch (\Exception $e) {
      // If an error happened in the subrequest we can't do much else. Instead,       // just log it. The DefaultExceptionSubscriber will catch the original       // exception and handle it normally.       $error = Error::decodeException($e);
      $this->logger->log($error['severity_level'], Error::DEFAULT_ERROR_MESSAGE, $error);
    }
  }

}
return $this->errorLevel;
  }

  /** * Handles exceptions for this subscriber. * * @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event * The event to process. */
  public function onException(ExceptionEvent $event) {
    $exception = $event->getThrowable();
    $error = Error::decodeException($exception);

    // Display the message if the current error reporting level allows this type     // of message to be displayed, and unconditionally in update.php.     $message = '';
    if ($this->isErrorDisplayable($error)) {
      // If error type is 'User notice' then treat it as debug information       // instead of an error message.       if ($error['%type'] == 'User notice') {
        $error['%type'] = 'Debug';
      }

      

  protected function handleException(\Exception $exception$save = TRUE) {
    $result = Error::decodeException($exception);
    $message = $result['@message'] . ' (' . $result['%file'] . ':' . $result['%line'] . ')';
    if ($save) {
      $this->saveMessage($message);
    }
    $this->message->display($message, 'error');
  }

  /** * Checks for exceptional conditions, and display feedback. */
  protected function checkStatus() {
    

        else {
          $this->doOne($entity$callback);
        }
      }
      catch (\Throwable $throwable) {
        if (!$continue_on_error) {
          throw $throwable;
        }
        $context['%view'] = $entity->id();
        $context['%entity_type'] = $entity_type_id;
        $context += Error::decodeException($throwable);
        \Drupal::logger('update')->error('Unable to update %entity_type %view due to error @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
        $sandbox[self::SANDBOX_KEY]['failed_entity_ids'][] = $entity->id();
      }
    }

    $sandbox['#finished'] = empty($sandbox[self::SANDBOX_KEY]['entities']) ? 1 : ($sandbox[self::SANDBOX_KEY]['count'] - count($sandbox[self::SANDBOX_KEY]['entities'])) / $sandbox[self::SANDBOX_KEY]['count'];
    if (!empty($sandbox[self::SANDBOX_KEY]['failed_entity_ids'])) {
      $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
      if (\Drupal::moduleHandler()->moduleExists('dblog')) {
        return new TranslatableMarkup('Updates failed for the entity type %entity_type, for %entity_ids. <a href=":url">Check the logs</a>.', [
          '%entity_type' => $entity_type->getLabel(),
          
/** * Log 403 errors. * * @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event * The event to process. */
  public function on403(ExceptionEvent $event) {
    // Log the exception with the page where it happened so that admins know     // why access was denied.     $exception = $event->getThrowable();
    $error = Error::decodeException($exception);
    unset($error['@backtrace_string']);
    $error['@uri'] = $event->getRequest()->getRequestUri();
    $this->logger->get('access denied')->warning('Path: @uri. ' . Error::DEFAULT_ERROR_MESSAGE, $error);
  }

  /** * Log 404 errors. * * @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event * The event to process. */
  

  public function fetch(bool $force = FALSE): array {
    $announcements = $this->tempStore->get('announcements');
    if ($force || $announcements === NULL) {
      try {
        $feed_content = (string) $this->httpClient->get($this->feedUrl)->getBody();
      }
      catch (\Exception $e) {
        $this->logger->error(Error::DEFAULT_ERROR_MESSAGE, Error::decodeException($e));
        throw $e;
      }

      $announcements = Json::decode($feed_content);
      if (!isset($announcements['items'])) {
        $this->logger->error('The feed format is not valid.');
        throw new \Exception('Invalid format');
      }

      $announcements = $announcements['items'] ?? [];
      // Ensure that announcements reference drupal.org and are applicable to

  public static function logException(LoggerInterface $logger, \Throwable $exception, string $message = Error::DEFAULT_ERROR_MESSAGE, array $additional_variables = [], string $level = LogLevel::ERROR): void {
    $logger->log($level$messagestatic::decodeException($exception) + $additional_variables);
  }

  /** * Renders an exception error message without further exceptions. * * @param \Exception|\Throwable $exception * The exception object that was thrown. * * @return string * An error message. */
  
Home | Imprint | This part of the site doesn't use cookies.