Skip to content
Snippets Groups Projects
Commit f8aa6eec authored by Ted Bowman's avatar Ted Bowman
Browse files

add temp Error class

parent 4c61a803
No related branches found
No related tags found
1 merge request!967Issue #3391715: Change core merge request converter to either produce the Package Manager only MR or with AutoUpdates
......@@ -17,6 +17,7 @@ use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\automatic_updates\Validation\AdminStatusCheckMessages;
use Drupal\Core\Url;
use Drupal\package_manager\ComposerInspector;
use Drupal\package_manager\Error;
use Drupal\system\Controller\DbUpdateController;
/**
......@@ -276,7 +277,7 @@ function automatic_updates_preprocess_update_project_status(array &$variables) {
catch (RuntimeException $exception) {
// If for some reason we are not able to get the update recommendations
// do not alter the report.
watchdog_exception('automatic_updates', $exception);
Error::logException(\Drupal::logger('automatic_updates'), $exception);
return;
}
$variables['#attached']['library'][] = 'automatic_updates/update_status';
......
<?php
namespace Drupal\package_manager;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Drupal\Core\Utility\Error as CoreError;
/**
* Temporary class until 10.0.x is no longer supported.
*
* // @todo Remove this class in https://drupal.org/i/3377458.
*/
class Error {
/**
* Log a formatted exception message to the provided logger.
*
* @param \Psr\Log\LoggerInterface $logger
* The logger.
* @param \Throwable $exception
* The exception.
* @param string $message
* (optional) The message.
* @param array $additional_variables
* (optional) Any additional variables.
* @param string $level
* The PSR log level. Must be valid constant in \Psr\Log\LogLevel.
*/
public static function logException(LoggerInterface $logger, \Throwable $exception, string $message = CoreError::DEFAULT_ERROR_MESSAGE, array $additional_variables = [], string $level = LogLevel::ERROR): void {
$logger->log($level, $message, CoreError::decodeException($exception) + $additional_variables);
}
}
......@@ -121,6 +121,7 @@ class Converter {
$replacements = [
$old_machine_name => $new_machine_name,
'AutomaticUpdates' => 'AutoUpdates',
'use Drupal\package_manager\Error;' => 'use Drupal\Core\Utility\Error;',
];
foreach ($replacements as $search => $replace) {
static::renameFiles(static::getDirContents($core_module_path), $search, $replace);
......
......@@ -6,7 +6,7 @@ namespace Drupal\automatic_updates;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\CronInterface;
use Drupal\Core\Utility\Error;
use Drupal\package_manager\Error;
use Drupal\package_manager\PathLocator;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
......@@ -92,13 +92,7 @@ class CronUpdateRunner implements CronInterface, LoggerAwareInterface {
$pid = $this->commandExecutor->start($process);
}
catch (\Throwable $throwable) {
// @todo Just call Error::logException() in https://drupal.org/i/3377458.
if (method_exists(Error::class, 'logException')) {
Error::logException($this->logger, $throwable, 'Unable to start background update.');
}
else {
watchdog_exception('automatic_updates', $throwable, 'Unable to start background update.');
}
Error::logException($this->logger, $throwable, 'Unable to start background update.');
}
if ($process->isTerminated()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment