Skip to content

Commit

Permalink
move custom Exceptions in exception folder close #436
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-peugnet committed Oct 13, 2024
1 parent a171bec commit 0c8bbb7
Show file tree
Hide file tree
Showing 21 changed files with 56 additions and 26 deletions.
2 changes: 2 additions & 0 deletions app/class/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Wcms;

use Wcms\Exception\Filesystemexception;

abstract class Config
{
protected static $pagetable = 'mystore';
Expand Down
1 change: 1 addition & 0 deletions app/class/Controlleradmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Wcms;

use RuntimeException;
use Wcms\Exception\Filesystemexception;

class Controlleradmin extends Controller
{
Expand Down
1 change: 1 addition & 0 deletions app/class/Controllerapimedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use AltoRouter;
use Error;
use RuntimeException;
use Wcms\Exception\Filesystemexception;

class Controllerapimedia extends Controllerapi
{
Expand Down
1 change: 1 addition & 0 deletions app/class/Controllermedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use AltoRouter;
use RuntimeException;
use Wcms\Exception\Filesystemexception\Folderexception;
use Wcms\Exception\Forbiddenexception;

class Controllermedia extends Controller
Expand Down
1 change: 1 addition & 0 deletions app/class/Controllerpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DateTimeImmutable;
use RuntimeException;
use Wcms\Exception\Filesystemexception;

class Controllerpage extends Controller
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Wcms;
namespace Wcms\Exception;

use RuntimeException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace Wcms;
namespace Wcms\Exception\Filesystemexception;

use Wcms\Exception\Filesystemexception;

class Chmodexception extends Filesystemexception
{
Expand Down
9 changes: 9 additions & 0 deletions app/class/Exception/Filesystemexception/Fileexception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Wcms\Exception\Filesystemexception;

use Wcms\Exception\Filesystemexception;

class Fileexception extends Filesystemexception
{
}
9 changes: 9 additions & 0 deletions app/class/Exception/Filesystemexception/Folderexception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Wcms\Exception\Filesystemexception;

use Wcms\Exception\Filesystemexception;

class Folderexception extends Filesystemexception
{
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Wcms;
namespace Wcms\Exception\Filesystemexception;

use Throwable;
use Wcms\Exception\Filesystemexception;

/**
* File not found
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Wcms;
namespace Wcms\Exception\Filesystemexception;

use Throwable;
use Wcms\Exception\Filesystemexception;

/**
* Error while trying to unlink file on the filesystem
Expand Down
7 changes: 0 additions & 7 deletions app/class/Fileexception.php

This file was deleted.

7 changes: 0 additions & 7 deletions app/class/Folderexception.php

This file was deleted.

7 changes: 6 additions & 1 deletion app/class/Fs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

use DomainException;
use LogicException;
use RuntimeException;
use Wcms\Exception\Filesystemexception;
use Wcms\Exception\Filesystemexception\Chmodexception;
use Wcms\Exception\Filesystemexception\Fileexception;
use Wcms\Exception\Filesystemexception\Folderexception;
use Wcms\Exception\Filesystemexception\Notfoundexception;
use Wcms\Exception\Filesystemexception\Unlinkexception;

/**
* File system related tools. No Wcms specific param should be set here.
Expand Down
1 change: 1 addition & 0 deletions app/class/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DateTime;
use DomainException;
use RuntimeException;
use Wcms\Exception\Filesystemexception\Fileexception;

class Media extends Item
{
Expand Down
4 changes: 3 additions & 1 deletion app/class/Modelmedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use RuntimeException;
use Imagick;
use ImagickException;
use RangeException;
use Wcms\Exception\Filesystemexception;
use Wcms\Exception\Filesystemexception\Fileexception;
use Wcms\Exception\Filesystemexception\Folderexception;
use Wcms\Exception\Forbiddenexception;

class Modelmedia extends Model
Expand Down
2 changes: 2 additions & 0 deletions app/class/Modelpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use InvalidArgumentException;
use RangeException;
use RuntimeException;
use Wcms\Exception\Filesystemexception;
use Wcms\Exception\Filesystemexception\Notfoundexception;

class Modelpage extends Modeldb
{
Expand Down
3 changes: 2 additions & 1 deletion app/class/Servicefont.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Wcms;

use RuntimeException ;
use RuntimeException;
use Wcms\Exception\Filesystemexception;

class Servicefont
{
Expand Down
7 changes: 5 additions & 2 deletions app/class/Servicerss.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
use LogicException;
use RuntimeException;
use Wcms\Exception\Database\Notfoundexception;
use Wcms\Notfoundexception as WcmsNotfoundexception;
use Wcms\Exception\Filesystemexception;
use Wcms\Exception\Filesystemexception\Folderexception;
use Wcms\Exception\Filesystemexception\Notfoundexception as FilesystemexceptionNotfoundexception;
use Wcms\Exception\Filesystemexception\Unlinkexception;

class Servicerss
{
Expand Down Expand Up @@ -233,7 +236,7 @@ public static function removeatom(string $id): void
{
try {
Fs::deletefile(self::atomfile($id));
} catch (WcmsNotfoundexception $e) {
} catch (FilesystemexceptionNotfoundexception $e) {
// do nothing, this means file is already deleted
} catch (Unlinkexception $e) {
throw new RuntimeException("RSS atom file deletion error", 0, $e);
Expand Down
6 changes: 4 additions & 2 deletions app/class/Servicetags.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Wcms;

use Exception;
use Wcms\Exception\Filesystemexception;
use Wcms\Exception\Filesystemexception\Fileexception;
use Wcms\Exception\Filesystemexception\Notfoundexception;

class Servicetags
{
Expand All @@ -16,7 +18,7 @@ public function taglist(): array
try {
$tagfile = Fs::readfile(Model::TAGS_FILE);
} catch (Notfoundexception $e) {
// This mean the tag fille does not exist
// This mean the tag file does not exist
return [];
}
$tagdata = json_decode($tagfile, true);
Expand Down
2 changes: 1 addition & 1 deletion app/fn/fn.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Wcms\Folderexception;
use Wcms\Exception\Filesystemexception\Folderexception;

function readablesize($bytes, $base = 2 ** 10)
{
Expand Down

0 comments on commit 0c8bbb7

Please sign in to comment.