added more exception handling

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-02-20 19:39:54 +01:00
parent b5351ab085
commit 86822f4cbb
1 changed files with 14 additions and 4 deletions

View File

@ -1,9 +1,12 @@
#!/usr/local/bin/php81
#!/usr/bin/keyhelp-php81
<?php declare(strict_types=1);
namespace App\Controller;
//#!/usr/bin/keyhelp-php81
// & ~E_DEPRECATED is needed because of a bug in PhpStorm
use DI\DependencyException;
use DI\NotFoundException;
use Exception;
error_reporting(error_level: E_ALL & ~E_DEPRECATED);
if (php_sapi_name() !== 'cli') {
@ -68,8 +71,15 @@ if (array_key_exists(key: 'V', array: $options) || array_key_exists(key: 'verbos
$arguments = array_slice(array: $argv, offset: $restIndex);
$app = new BindAPI(config: $config, argumentsCount: count(value: $arguments), arguments: $arguments);
$app->runCommand();
try {
$app = new BindAPI(config: $config, argumentsCount: count(value: $arguments), arguments: $arguments);
$app->runCommand();
} catch (DependencyException|NotFoundException $e) {
echo $e->getMessage();
exit(1);
} catch (Exception $e) {
echo $e->getMessage();
}
/**