function FailureMarker::getMessage

Gets the message from the file if it exists.

Parameters

bool $include_backtrace: Whether to include the backtrace in the message. Defaults to TRUE. May be set to FALSE in a context where it does not make sense to include, such as emails.

Return value

string|null The message from the file if it exists, otherwise NULL.

Throws

\Drupal\package_manager\Exception\FailureMarkerExistsException Thrown if failure marker exists but cannot be decoded.

1 call to FailureMarker::getMessage()
FailureMarker::assertNotExists in core/modules/package_manager/src/FailureMarker.php
Asserts the failure file doesn't exist.

File

core/modules/package_manager/src/FailureMarker.php, line 111

Class

FailureMarker
Handles failure marker file operation.

Namespace

Drupal\package_manager

Code

public function getMessage(bool $include_backtrace = TRUE) : ?string {
  $data = $this->getData();
  if ($data === NULL) {
    return NULL;
  }
  $message = $data['message'];
  if ($data['throwable_class']) {
    $message .= sprintf(' Caused by %s, with this message: %s', $data['throwable_class'], $data['throwable_message']);
    if ($include_backtrace) {
      $message .= "\nBacktrace:\n" . $data['throwable_backtrace'];
    }
  }
  return $message;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.