Unverified Commit 0415f597 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3260044 by kim.pepper, andypost, daffie, mfb: Add a constant for watchdog_exception message

parent 7ca36cfc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia

  // Use a default value if $message is not set.
  if (empty($message)) {
    $message = '%type: @message in %function (line %line of %file).';
    $message = Error::DEFAULT_ERROR_MESSAGE;
  }

  if ($link) {
+5 −5
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
    catch (\Exception $e) {
      // We can't log, for example because the database connection is not
      // available. At least try to log to PHP error log.
      error_log(strtr('Failed to log error: %type: @message in %function (line %line of %file). @backtrace_string', $error));
      error_log(strtr('Failed to log error: ' . Error::DEFAULT_ERROR_MESSAGE . ' @backtrace_string', $error));
    }
  }

@@ -190,7 +190,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
    if ($fatal) {
      // When called from CLI, simply output a plain text message.
      // Should not translate the string to avoid errors producing more errors.
      $response->setContent(html_entity_decode(strip_tags(new FormattableMarkup('%type: @message in %function (line %line of %file).', $error))) . "\n");
      $response->setContent(html_entity_decode(strip_tags(new FormattableMarkup(Error::DEFAULT_ERROR_MESSAGE, $error))) . "\n");
      $response->send();
      exit(1);
    }
@@ -201,7 +201,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
      if (error_displayable($error)) {
        // When called from JavaScript, simply output the error message.
        // Should not translate the string to avoid errors producing more errors.
        $response->setContent(new FormattableMarkup('%type: @message in %function (line %line of %file).', $error));
        $response->setContent(new FormattableMarkup(Error::DEFAULT_ERROR_MESSAGE, $error));
        $response->send();
      }
      exit;
@@ -240,7 +240,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
        // We use \Drupal\Component\Render\FormattableMarkup directly here,
        // rather than use t() since we are in the middle of error handling, and
        // we don't want t() to cause further errors.
        $message = new FormattableMarkup('%type: @message in %function (line %line of %file).', $error);
        $message = new FormattableMarkup(Error::DEFAULT_ERROR_MESSAGE, $error);
      }
      else {
        // With verbose logging, we will also include a backtrace.
@@ -252,7 +252,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
        array_shift($backtrace);
        // Generate a backtrace containing only scalar argument values.
        $error['@backtrace'] = Error::formatBacktrace($backtrace);
        $message = new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
        $message = new FormattableMarkup(Error::DEFAULT_ERROR_MESSAGE . ' <pre class="backtrace">@backtrace</pre>', $error);
      }
    }

+2 −2
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {

      $variables = Error::decodeException($e);
      unset($variables['backtrace'], $variables['exception'], $variables['severity_level']);
      $ret['#abort'] = ['success' => FALSE, 'query' => t('%type: @message in %function (line %line of %file).', $variables)];
      $ret['#abort'] = ['success' => FALSE, 'query' => t(Error::DEFAULT_ERROR_MESSAGE, $variables)];
    }
  }

@@ -248,7 +248,7 @@ function update_invoke_post_update($function, &$context) {
      unset($variables['backtrace'], $variables['exception']);
      $ret['#abort'] = [
        'success' => FALSE,
        'query' => t('%type: @message in %function (line %line of %file).', $variables),
        'query' => t(Error::DEFAULT_ERROR_MESSAGE, $variables),
      ];
    }
  }
+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ protected function makeSubrequest(ExceptionEvent $event, $url, $status_code) {
      // just log it. The DefaultExceptionSubscriber will catch the original
      // exception and handle it normally.
      $error = Error::decodeException($e);
      $this->logger->log($error['severity_level'], '%type: @message in %function (line %line of %file).', $error);
      $this->logger->log($error['severity_level'], Error::DEFAULT_ERROR_MESSAGE, $error);
    }
  }

+2 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public function on403(ExceptionEvent $event) {
    $error = Error::decodeException($exception);
    unset($error['@backtrace_string']);
    $error['@uri'] = $event->getRequest()->getRequestUri();
    $this->logger->get('access denied')->warning('Path: @uri. %type: @message in %function (line %line of %file).', $error);
    $this->logger->get('access denied')->warning('Path: @uri. ' . Error::DEFAULT_ERROR_MESSAGE, $error);
  }

  /**
@@ -67,7 +67,7 @@ public function on404(ExceptionEvent $event) {
  public function onError(ExceptionEvent $event) {
    $exception = $event->getThrowable();
    $error = Error::decodeException($exception);
    $this->logger->get('php')->log($error['severity_level'], '%type: @message in %function (line %line of %file).', $error);
    $this->logger->get('php')->log($error['severity_level'], Error::DEFAULT_ERROR_MESSAGE, $error);

    $is_critical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500;
    if ($is_critical) {
Loading