Skip to content

Commit

Permalink
Support handling of rector fatal errors (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored Aug 13, 2023
1 parent 1622e1d commit 16309c5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/CsFixerResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ public function getFileDiffs(): array
}
return $fileDiffs;
}

/**
* @return list<string>
*/
public function getFatalErrors(): array {
return [];
}
}
7 changes: 7 additions & 0 deletions lib/RectorResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,11 @@ public function getAppliedRectors(): array

return array_unique($rectors);
}

/**
* @return list<string>
*/
public function getFatalErrors(): array {
return $this->json['fatal_errors'] ?? [];
}
}
9 changes: 9 additions & 0 deletions pages/apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

$result = RexFactor::runRexFactor($addon, $setList, $targetVersion, false, $skipList->toRectorSkipList());

$fatalErrors = $result->getFatalErrors();
if ($fatalErrors !== []) {
foreach($fatalErrors as $error) {
echo rex_view::error($error);
}

return;
}

$total = $result->getTotals();
$content = '';
if ($total['changed_files'] > 0) {
Expand Down
9 changes: 9 additions & 0 deletions pages/preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@

$result = RexFactor::runRexFactor($addon, $setList, $targetVersion, true, $skipList->toRectorSkipList());

$fatalErrors = $result->getFatalErrors();
if ($fatalErrors !== []) {
foreach($fatalErrors as $error) {
echo rex_view::error($error);
}

return;
}

$html = $content = $diffout = '';
$total = $result->getTotals();
if ($total['changed_files'] > 0) {
Expand Down

0 comments on commit 16309c5

Please sign in to comment.