From 1ba7872dcb5c165276dc59d5d7de309ef9260979 Mon Sep 17 00:00:00 2001 From: techno-express Date: Wed, 3 Mar 2021 20:36:10 -0500 Subject: [PATCH] updates to handle "complex" exceptions, and capture code coverage --- .github/workflows/spawn_macos.yml | 3 +-- Spawn/SerializableException.php | 11 ++++++++--- phpunit.xml.dist | 5 +++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/spawn_macos.yml b/.github/workflows/spawn_macos.yml index fd26cbc..cfaa6ec 100644 --- a/.github/workflows/spawn_macos.yml +++ b/.github/workflows/spawn_macos.yml @@ -25,9 +25,8 @@ jobs: - name: Install dependencies run: composer install - name: Test with phpunit - run: vendor/bin/phpunit -d zend.enable_gc=0 --coverage-clover=coverage/phpunit/clover.xml + run: vendor/bin/phpunit -d zend.enable_gc=0 --coverage-clover=coverage.xml - name: Submit code coverage - if: ${{ success() }} || ${{ failure() }} uses: codecov/codecov-action@v1 with: file: ./coverage.xml # optional diff --git a/Spawn/SerializableException.php b/Spawn/SerializableException.php index 2aa0e09..d67548d 100644 --- a/Spawn/SerializableException.php +++ b/Spawn/SerializableException.php @@ -29,9 +29,14 @@ public function __construct(Throwable $exception) public function asThrowable(): Throwable { - /** @var Throwable $throwable */ - $throwable = new $this->class($this->message . "\n\n" . $this->trace); - + try { + /** @var Throwable $throwable */ + $throwable = new $this->class($this->message . "\n\n" . $this->trace); + } catch (Throwable $exception) { + // @codeCoverageIgnoreStart + $throwable = new \Exception($this->message . "\n\n" . $this->trace, 0, $exception); + // @codeCoverageIgnoreEnd + } return $throwable; } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 838d1a0..924f6d5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,4 +26,9 @@ + + + + +