1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
<?php
namespace ICanBoogie\MessageBus;
use ICanBoogie\Accessor\AccessorTrait;
class NoHandlerForMessage extends \LogicException implements Exception
{
use AccessorTrait;
private $_message;
protected function get_message()
{
return $this->_message;
}
public function __construct(Message $message, Exception $previous = null)
{
$this->_message = $message;
parent::__construct($this->format_message($message), 400, $previous);
}
private function format_message(Message $message)
{
$class = get_class($message);
return "There is no handler defined to handle messages of type `$class`";
}
}