Skip to content

Commit

Permalink
Add InvalidWatcherException::getWatcherId
Browse files Browse the repository at this point in the history
Resolves amphp#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.
  • Loading branch information
kelunik committed Nov 6, 2016
1 parent aef839e commit f41eb23
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Loop/InvalidWatcherException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit f41eb23

Please sign in to comment.