You are here

public static function ExceptionHandler::handleSanityException in Module Builder 8.3

Handle a sanity exception from the library and output a message.

Parameters

DrupalCodeBuilder\Exception\SanityException $e: A sanity exception object.

2 calls to ExceptionHandler::handleSanityException()
ComponentFormBase::buildForm in src/Form/ComponentFormBase.php
Form constructor.
ModuleBuilderComponentListBuilder::render in src/ModuleBuilderComponentListBuilder.php
Builds the entity listing as renderable array for table.html.twig.

File

src/ExceptionHandler.php, line 19

Class

ExceptionHandler
Handles exceptions from the library and outputs messages.

Namespace

Drupal\module_builder

Code

public static function handleSanityException(SanityException $e) {
  $failed_sanity_level = $e
    ->getFailedSanityLevel();
  switch ($failed_sanity_level) {
    case 'data_directory_exists':
      \Drupal::messenger()
        ->addError(t("The component data directory could not be created or is not writable."));
      break;
    case 'component_data_processed':
      \Drupal::messenger()
        ->addError(t("No component data is present. Go to the <a href=\":url\">'Analyse code' page</a> to collect data about your codebase's Drupal components.", [
        ':url' => Url::fromRoute('module_builder.analyse')
          ->toString(),
      ]));
      break;
  }
}