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 2170c2a commit 875f27f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 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,12 +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) {
$this->logger->error('Generating the class diagram failed', ['error' => $e->getMessage()]);

return null;
}
Expand Down

0 comments on commit 875f27f

Please sign in to comment.