mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
Add exceptions for more connection failures
This commit is contained in:
parent
40fa68e426
commit
c8a93a9033
6 changed files with 82 additions and 0 deletions
11
src/Exception/ConnectionRefusedException.php
Normal file
11
src/Exception/ConnectionRefusedException.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
||||||
|
* This file is licensed under the Licensed under the MIT license:
|
||||||
|
* http://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Icewind\SMB\Exception;
|
||||||
|
|
||||||
|
class ConnectionRefusedException extends ConnectException {
|
||||||
|
}
|
||||||
11
src/Exception/HostDownException.php
Normal file
11
src/Exception/HostDownException.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
||||||
|
* This file is licensed under the Licensed under the MIT license:
|
||||||
|
* http://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Icewind\SMB\Exception;
|
||||||
|
|
||||||
|
class HostDownException extends ConnectException {
|
||||||
|
}
|
||||||
11
src/Exception/NoRouteToHostException.php
Normal file
11
src/Exception/NoRouteToHostException.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
||||||
|
* This file is licensed under the Licensed under the MIT license:
|
||||||
|
* http://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Icewind\SMB\Exception;
|
||||||
|
|
||||||
|
class NoRouteToHostException extends ConnectException {
|
||||||
|
}
|
||||||
11
src/Exception/TimeOutException.php
Normal file
11
src/Exception/TimeOutException.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
||||||
|
* This file is licensed under the Licensed under the MIT license:
|
||||||
|
* http://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Icewind\SMB\Exception;
|
||||||
|
|
||||||
|
class TimedOutException extends ConnectException {
|
||||||
|
}
|
||||||
|
|
@ -8,11 +8,15 @@
|
||||||
namespace Icewind\SMB;
|
namespace Icewind\SMB;
|
||||||
|
|
||||||
use Icewind\SMB\Exception\AlreadyExistsException;
|
use Icewind\SMB\Exception\AlreadyExistsException;
|
||||||
|
use Icewind\SMB\Exception\ConnectionRefusedException;
|
||||||
use Icewind\SMB\Exception\Exception;
|
use Icewind\SMB\Exception\Exception;
|
||||||
use Icewind\SMB\Exception\ForbiddenException;
|
use Icewind\SMB\Exception\ForbiddenException;
|
||||||
|
use Icewind\SMB\Exception\HostDownException;
|
||||||
use Icewind\SMB\Exception\InvalidTypeException;
|
use Icewind\SMB\Exception\InvalidTypeException;
|
||||||
|
use Icewind\SMB\Exception\NoRouteToHostException;
|
||||||
use Icewind\SMB\Exception\NotEmptyException;
|
use Icewind\SMB\Exception\NotEmptyException;
|
||||||
use Icewind\SMB\Exception\NotFoundException;
|
use Icewind\SMB\Exception\NotFoundException;
|
||||||
|
use Icewind\SMB\Exception\TimedOutException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Low level wrapper for libsmbclient-php for error handling
|
* Low level wrapper for libsmbclient-php for error handling
|
||||||
|
|
@ -46,6 +50,14 @@ class NativeState {
|
||||||
throw new InvalidTypeException($path, $error);
|
throw new InvalidTypeException($path, $error);
|
||||||
case 39:
|
case 39:
|
||||||
throw new NotEmptyException($path, $error);
|
throw new NotEmptyException($path, $error);
|
||||||
|
case 110:
|
||||||
|
throw new TimedOutException($path, $error);
|
||||||
|
case 111:
|
||||||
|
throw new ConnectionRefusedException($path, $error);
|
||||||
|
case 112:
|
||||||
|
throw new HostDownException($path, $error);
|
||||||
|
case 113:
|
||||||
|
throw new NoRouteToHostException($path, $error);
|
||||||
default:
|
default:
|
||||||
$message = 'Unknown error (' . $error . ')';
|
$message = 'Unknown error (' . $error . ')';
|
||||||
if ($path) {
|
if ($path) {
|
||||||
|
|
|
||||||
|
|
@ -505,4 +505,30 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals($size, $info->getSize());
|
$this->assertEquals($size, $info->getSize());
|
||||||
$this->assertFalse($info->isHidden());
|
$this->assertFalse($info->isHidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDelAfterStat() {
|
||||||
|
$name = 'foo.txt';
|
||||||
|
$txtFile = $this->getTextFile();
|
||||||
|
|
||||||
|
$this->share->put($txtFile, $this->root . '/' . $name);
|
||||||
|
unlink($txtFile);
|
||||||
|
|
||||||
|
$this->share->stat($this->root . '/' . $name);
|
||||||
|
$this->share->del($this->root . '/foo.txt');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @dataProvider nameProvider
|
||||||
|
*/
|
||||||
|
public function testDirPaths($name) {
|
||||||
|
$txtFile = $this->getTextFile();
|
||||||
|
$this->share->mkdir($this->root . '/' . $name);
|
||||||
|
$this->share->put($txtFile, $this->root . '/' . $name . '/' . $name);
|
||||||
|
unlink($txtFile);
|
||||||
|
|
||||||
|
$content = $this->share->dir($this->root . '/' . $name);
|
||||||
|
$this->assertCount(1, $content);
|
||||||
|
$this->assertEquals($name, $content[0]->getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue