1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 18:38:17 +01:00
amp/src/Loop/InvalidWatcherException.php
Niklas Keller f41eb23a8d 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.
2016-11-06 18:38:20 +01:00

38 lines
934 B
PHP

<?php
namespace Interop\Async\Loop;
/**
* MUST be thrown if any operation (except disable() and cancel()) is attempted with an invalid watcher identifier.
*
* An invalid watcher identifier is any identifier that is not yet emitted by the driver or cancelled by the user.
*/
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;
}
}