Skip to content

Commit

Permalink
[FIX] Catch exception to prevent crash
Browse files Browse the repository at this point in the history
When the process fails with an exception the rendering should not stop.
We just want to continue to the rendering.
  • Loading branch information
jaapio committed Dec 30, 2023
1 parent 9bebd3a commit d8f1e55
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/guides-graphs/src/Graphs/Renderer/PlantumlRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace phpDocumentor\Guides\Graphs\Renderer;

use Psr\Log\LoggerInterface;
use Symfony\Component\Process\Exception\RuntimeException;
use Symfony\Component\Process\Process;

use function file_get_contents;
Expand Down Expand Up @@ -44,13 +45,17 @@ public function render(string $diagram): string|null

$pumlFileLocation = tempnam(sys_get_temp_dir() . '/phpdocumentor', 'pu_');
file_put_contents($pumlFileLocation, $output);
try {
$process = new Process([$this->plantUmlBinaryPath, '-tsvg', $pumlFileLocation], __DIR__, null, null, 600.0);
$process->run();

$process = new Process([$this->plantUmlBinaryPath, '-tsvg', $pumlFileLocation], __DIR__, null, null, 600.0);
$process->run();

if (!$process->isSuccessful()) {
$this->logger->error('Generating the class diagram failed', ['error' => $process->getErrorOutput()]);
if (!$process->isSuccessful()) {
$this->logger->error('Generating the class diagram failed', ['error' => $process->getErrorOutput()]);

return null;
}
} catch(RuntimeException $e) {

Check failure on line 57 in packages/guides-graphs/src/Graphs/Renderer/PlantumlRenderer.php

View workflow job for this annotation

GitHub Actions / Coding Standards

Expected 1 space after CATCH keyword; 0 found
$this->logger->error('Generating the class diagram failed', ['error' => $e->getMessage()]);
return null;

Check failure on line 59 in packages/guides-graphs/src/Graphs/Renderer/PlantumlRenderer.php

View workflow job for this annotation

GitHub Actions / Coding Standards

Expected 1 line before "return", found 0.
}

Expand Down

0 comments on commit d8f1e55

Please sign in to comment.