Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Exceptions/IO/Filesystem/DirectoryAlreadyExistsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Exceptions\IO\Filesystem;

use Exceptions\Tag\AlreadyExistsException;

/**
* Use this exception when your code tries to create a local directory but it already exists.
*
* @author Mathieu Dumoulin aka CrazyCodr <thecrazycodr@gmail.com>
* @license MIT
*/
class DirectoryAlreadyExistsException extends FilesystemException implements AlreadyExistsException
{
public function __construct(
$message = 'Cannot find specified directory',
$code = 0,
$previous = null
) {
parent::__construct($message, $code, $previous);
}
}
22 changes: 22 additions & 0 deletions Exceptions/IO/Filesystem/FileAlreadyExistsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Exceptions\IO\Filesystem;

use Exceptions\Tag\AlreadyExistsException;

/**
* Use this exception when your code tries to create a file but it already exists.
*
* @author Mathieu Dumoulin aka CrazyCodr <thecrazycodr@gmail.com>
* @license MIT
*/
class FileAlreadyExistsException extends FilesystemException implements AlreadyExistsException
{
public function __construct(
$message = 'Cannot find specified file',
$code = 0,
$previous = null
) {
parent::__construct($message, $code, $previous);
}
}
15 changes: 15 additions & 0 deletions Exceptions/Tag/AlreadyExistsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Exceptions\Tag;

/**
* This is a tag interface that is used to conveys a shared means throughout many different exceptions in many
* different namespaces. If you want to catch a potential error about something that already exists, you would try to
* catch any exception that implements this interface.
*
* @author Mathieu Dumoulin aka CrazyCodr <thecrazycodr@gmail.com>
* @license MIT
*/
interface AlreadyExistsException
{
}
2 changes: 2 additions & 0 deletions Tests/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public function providesConstructorTestClasses()
[\Exceptions\Http\Server\NotImplementedException::class],
[\Exceptions\Http\Server\ServiceUnavailableException::class],
[\Exceptions\IO\Filesystem\FileNotWritableException::class],
[\Exceptions\IO\Filesystem\FileAlreadyExistsException::class],
[\Exceptions\IO\Filesystem\NotAFileException::class],
[\Exceptions\IO\Filesystem\NotADirectoryException::class],
[\Exceptions\IO\Filesystem\FileNotFoundException::class],
[\Exceptions\IO\Filesystem\DirectoryNotWritableException::class],
[\Exceptions\IO\Filesystem\DirectoryAlreadyExistsException::class],
[\Exceptions\IO\Filesystem\DirectoryNotFoundException::class],
[\Exceptions\IO\Filesystem\FileNotReadableException::class],
[\Exceptions\IO\Filesystem\DirectoryNotReadableException::class],
Expand Down