Skip to content

Commit

Permalink
Handle errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Jun 30, 2017
1 parent fbe60e2 commit 02ef254
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions bin/database-to-plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,21 @@ if (empty($databaseName)) {
exit(2);
}

$reader = new Frontend\Reader($databaseDsn, $databaseUser, $databasePassword);
$backend = new $backendName();
try {
$reader = new Frontend\Reader($databaseDsn, $databaseUser, $databasePassword);
$backend = new $backendName();

echo $backend->visit($reader->read($databaseName));
echo $backend->visit($reader->read($databaseName));
} catch (Exception $e) {
ob_start();

Console\Cursor::colorize('foreground(white) background(red)');
echo $e->getMessage(), "\n";
Console\Cursor::colorize('normal');
$content = ob_get_contents();

ob_end_clean();

file_put_contents('php://stderr', $content);
exit(2);
}

0 comments on commit 02ef254

Please sign in to comment.