Skip to content

Commit

Permalink
Improves error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Mar 16, 2024
1 parent 8b547fc commit fb4061e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Fixers/LaravelBladeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ protected function applyFix(SplFileInfo $file, Tokens $tokens): void
$result = app(Prettier::class)->run([$path]);

if ($result->failed()) {
throw new PrettierException($result->errorOutput());
$error = $result->errorOutput();

if (str($error)->startsWith('[error]') && str($error)->contains('SyntaxError:')) {
$error = str($error)->after('SyntaxError: ')->before("\n")->value();
}

throw new PrettierException($error);
}

$tokens->setCode($result->output());
Expand Down

0 comments on commit fb4061e

Please sign in to comment.