beter catching of errors

This commit is contained in:
Robin Appelman 2013-06-17 15:11:06 +02:00
commit cb96c44176
2 changed files with 15 additions and 1 deletions

View file

@ -184,6 +184,8 @@ class Share {
}
/**
* check output for errors
*
* @param $lines
*
* @throws NotFoundException
@ -202,7 +204,12 @@ class Share {
throw new NotFoundException();
}
$parts = explode(' ', $lines[0]);
$error = array_pop($parts);
$error = false;
foreach ($parts as $part) {
if (substr($part, 0, 9) === 'NT_STATUS') {
$error = $part;
}
}
switch ($error) {
case ErrorCodes::PathNotFound:
case ErrorCodes::ObjectNotFound:

View file

@ -262,4 +262,11 @@ class Share extends \PHPUnit_Framework_TestCase {
public function testDirNonExisting() {
$this->share->dir('/foobar/asd');
}
/**
* @expectedException \SMB\NotFoundException
*/
public function testRmDirNonExisting(){
$this->share->rmdir('/foobar/asd');
}
}