diff --git a/src/Connection.php b/src/Connection.php index 0196231..661a361 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -34,10 +34,14 @@ public function write($input) { parent::write($input . PHP_EOL); } + /** + * @throws ConnectException + */ public function clearTillPrompt() { $this->write(''); do { $promptLine = $this->readLine(); + $this->parser->checkConnectionError($promptLine); } while (!$this->isPrompt($promptLine)); $this->write(''); $this->readLine(); diff --git a/src/Parser.php b/src/Parser.php index 30dce39..a300321 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -81,6 +81,7 @@ public function checkForError($output, $path) { * @throws AuthenticationException * @throws InvalidHostException * @throws NoLoginServerException + * @throws AccessDeniedException */ public function checkConnectionError($line) { $line = rtrim($line, ')'); @@ -99,6 +100,9 @@ public function checkConnectionError($line) { if (substr($line, -26) === ErrorCodes::NoLogonServers) { throw new NoLoginServerException('No login server'); } + if (substr($line, -23) === ErrorCodes::AccessDenied) { + throw new AccessDeniedException('Access denied'); + } } public function parseMode($mode) {