Skip to content

Commit

Permalink
[Reveal latte] Better error handling (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
lulco authored Jul 13, 2022
1 parent f6342d4 commit ba982e6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/reveal-latte/src/Rules/LatteCompleteCheckRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ public function processNode(Node $node, Scope $scope): array

$uniqueErrorsByHash = [];
foreach ($errors as $error) {
/** @var RuleError&FileRuleError&LineRuleError $error */
$errorHash = $error->getMessage() . $error->getFile() . $error->getLine();
$errorHash = $error->getMessage();
if ($error instanceof FileRuleError) {
$errorHash .= $error->getFile();
}
if ($error instanceof LineRuleError) {
$errorHash .= $error->getLine();
}
$uniqueErrorsByHash[$errorHash] = $error;
}

Expand Down Expand Up @@ -169,9 +174,8 @@ private function processTemplateFilePath(
$scope,
$componentNamesAndTypes
);
} catch (Throwable) {
// missing include/layout template or something else went wrong → we cannot analyse template here
$errorMessage = sprintf('Template file "%s" does not exist', $templateFilePath);
} catch (Throwable $throwable) {
$errorMessage = $throwable->getMessage();
$ruleError = RuleErrorBuilder::message($errorMessage)->build();
return [$ruleError];
}
Expand Down

0 comments on commit ba982e6

Please sign in to comment.