Skip to content

Commit

Permalink
Use the general DomainEventException when failing for a body value
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilari Moragrega committed May 22, 2018
1 parent 45cd874 commit 76b8a72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Cmp/Queues/Domain/Event/DomainEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ public function getBodyValue($key, $default = null)
*
* @return mixed
*
* @throws \RuntimeException
* @throws DomainEventException
*/
public function getBodyValueOrFail($key)
{
if (!array_key_exists($key, $this->body)) {
throw new \RuntimeException("No value in the body found for Key: $key");
throw new DomainEventException("No value in the body found for Key: $key");
}

return $this->body[$key];
Expand Down
3 changes: 2 additions & 1 deletion tests/spec/Cmp/Queues/Domain/Event/DomainEventSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace spec\Cmp\Queues\Domain\Event;

use Cmp\Queues\Domain\Event\Exception\DomainEventException;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

Expand Down Expand Up @@ -110,6 +111,6 @@ function it_can_get_body_values()

function it_can_get_body_values_or_fail()
{
$this->shouldThrow(\RuntimeException::class)->duringGetBodyValueOrFail("nope");
$this->shouldThrow(DomainEventException::class)->duringGetBodyValueOrFail("nope");
}
}

0 comments on commit 76b8a72

Please sign in to comment.