From 21ee2bd0d746752876cc33227d1c8f3b771e93ae Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 11 May 2020 23:20:28 +0200 Subject: [PATCH] Exception handling: Added NullHandler to be used in commands --- bin/migrate | 6 +++++ src/Exceptions/Handlers/NullHandler.php | 18 ++++++++++++++ .../Exceptions/Handlers/NullHandlerTest.php | 24 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/Exceptions/Handlers/NullHandler.php create mode 100644 tests/Unit/Exceptions/Handlers/NullHandlerTest.php diff --git a/bin/migrate b/bin/migrate index 6336e387..3aa021d4 100755 --- a/bin/migrate +++ b/bin/migrate @@ -5,6 +5,8 @@ use Composer\Autoload\ClassLoader; use Engelsystem\Application; use Engelsystem\Database\Migration\Migrate; use Engelsystem\Database\Migration\MigrationServiceProvider; +use Engelsystem\Exceptions\Handler; +use Engelsystem\Exceptions\Handlers\NullHandler; require_once __DIR__ . '/../includes/application.php'; @@ -15,6 +17,10 @@ $baseDir = __DIR__ . '/../db/migrations'; $app = app(); $app->register(MigrationServiceProvider::class); +/** @var Handler $errorHandler */ +$errorHandler = $app->get(Handler::class); +$errorHandler->setHandler(Handler::ENV_PRODUCTION, new NullHandler()); + /** @var Migrate $migration */ $migration = $app->get('db.migration'); $migration->setOutput(function ($text) { echo $text . PHP_EOL; }); diff --git a/src/Exceptions/Handlers/NullHandler.php b/src/Exceptions/Handlers/NullHandler.php new file mode 100644 index 00000000..f38441c4 --- /dev/null +++ b/src/Exceptions/Handlers/NullHandler.php @@ -0,0 +1,18 @@ +expectOutputString(''); + $handler->render($request, $exception); + } +}