2016-05-28 15:57:07 +02:00
|
|
|
<?php
|
|
|
|
|
2017-03-10 19:19:32 +01:00
|
|
|
namespace Amp\Loop;
|
2016-05-28 15:57:07 +02:00
|
|
|
|
|
|
|
/**
|
2016-09-21 18:05:59 +02:00
|
|
|
* 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.
|
2016-05-28 15:57:07 +02:00
|
|
|
*/
|
2017-03-10 21:58:46 +01:00
|
|
|
class InvalidWatcherException extends \Exception {
|
2016-11-06 18:38:20 +01:00
|
|
|
/** @var string */
|
|
|
|
private $watcherId;
|
2016-05-28 15:57:07 +02:00
|
|
|
|
2016-11-06 18:38:20 +01:00
|
|
|
/**
|
2017-03-10 21:58:46 +01:00
|
|
|
* @param string $watcherId The watcher identifier.
|
2016-11-06 18:38:20 +01:00
|
|
|
* @param string|null $message The exception message.
|
|
|
|
*/
|
2017-03-10 21:58:46 +01:00
|
|
|
public function __construct($watcherId, $message = null) {
|
2016-11-06 18:38:20 +01:00
|
|
|
$this->watcherId = $watcherId;
|
|
|
|
|
|
|
|
if ($message === null) {
|
2017-01-03 19:16:50 +01:00
|
|
|
$message = "An invalid watcher identifier has been used: '{$watcherId}'";
|
2016-11-06 18:38:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
parent::__construct($message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string The watcher identifier.
|
|
|
|
*/
|
2017-03-10 21:58:46 +01:00
|
|
|
public function getWatcherId() {
|
2016-11-06 18:38:20 +01:00
|
|
|
return $this->watcherId;
|
|
|
|
}
|
2016-05-28 15:57:07 +02:00
|
|
|
}
|