Skip to content

Commit

Permalink
Merge pull request #794 from phpDocumentor/fix/prevent-graph-render-c…
Browse files Browse the repository at this point in the history
…rash

[FIX] Catch exception to prevent crash
  • Loading branch information
jaapio authored Dec 30, 2023
2 parents 2170c2a + 875f27f commit 434b877
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 434b877

Please sign in to comment.