From f41eb23a8d1d2c00314912b94548601fa6077215 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sun, 6 Nov 2016 18:38:20 +0100 Subject: [PATCH] Add InvalidWatcherException::getWatcherId Resolves #98. I guess this exception should only be thrown if the passed watcher identifier is a string. If a wrong type is passed, some other exception should be thrown. --- src/Loop/InvalidWatcherException.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Loop/InvalidWatcherException.php b/src/Loop/InvalidWatcherException.php index 80cdf7d7..a80b20f8 100644 --- a/src/Loop/InvalidWatcherException.php +++ b/src/Loop/InvalidWatcherException.php @@ -9,5 +9,29 @@ */ class InvalidWatcherException extends \Exception { + /** @var string */ + private $watcherId; + /** + * @param string $watcherId The watcher identifier. + * @param string|null $message The exception message. + */ + public function __construct($watcherId, $message = null) + { + $this->watcherId = $watcherId; + + if ($message === null) { + $message = "An invalid watcher idenfier has been used: '{$watcherId}'"; + } + + parent::__construct($message); + } + + /** + * @return string The watcher identifier. + */ + public function getWatcherId() + { + return $this->watcherId; + } }