diff --git a/.harness.json b/.harness.json index 48eb33c..ca9fd08 100644 --- a/.harness.json +++ b/.harness.json @@ -11,7 +11,6 @@ "observed": [ "Code style", "Rector", - "Dependency analysis", - "Security patterns" + "Dependency analysis" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 072e128..dd198b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Registering a command outside WP-CLI throws the named `WpCliUnavailable` exception instead of a bare `\RuntimeException`. It extends `\RuntimeException`, and the message keeps its `WP-CLI is not available` prefix, followed by how to avoid it + ## [0.1.1] - 2026-10-13 ### Fixed diff --git a/src/Domain/Exceptions/WpCliUnavailable.php b/src/Domain/Exceptions/WpCliUnavailable.php new file mode 100644 index 0000000..58c9273 --- /dev/null +++ b/src/Domain/Exceptions/WpCliUnavailable.php @@ -0,0 +1,18 @@ +isAvailable()) { - throw new \RuntimeException('WP-CLI is not available'); + throw WpCliUnavailable::whenRegisteringACommand(); } $this->validateHandler($handler); diff --git a/tests/Unit/Domain/Exceptions/WpCliUnavailableTest.php b/tests/Unit/Domain/Exceptions/WpCliUnavailableTest.php new file mode 100644 index 0000000..eb5d259 --- /dev/null +++ b/tests/Unit/Domain/Exceptions/WpCliUnavailableTest.php @@ -0,0 +1,13 @@ +toBeInstanceOf(RuntimeException::class) + ->and($exception->getMessage())->toStartWith('WP-CLI is not available') + ->and($exception->getMessage())->toContain('isAvailable()'); +});