From c3db2f60d202983f42acec0b6fa7da92c09e7728 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Mon, 16 Aug 2021 17:06:02 +0100 Subject: [PATCH] [UTIL][EXCEPTIONS] Introduce NotStoredLocallyException --- src/Core/GSFile.php | 5 +++- .../Exception/NotStoredLocallyException.php | 30 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/Util/Exception/NotStoredLocallyException.php diff --git a/src/Core/GSFile.php b/src/Core/GSFile.php index a5367026b9..ad08a8cbfa 100644 --- a/src/Core/GSFile.php +++ b/src/Core/GSFile.php @@ -27,6 +27,7 @@ use App\Entity\Attachment; use App\Util\Common; use App\Util\Exception\DuplicateFoundException; use App\Util\Exception\NoSuchFileException; +use App\Util\Exception\NotStoredLocallyException; use App\Util\Exception\NotFoundException; use App\Util\Exception\ServerException; use SplFileInfo; @@ -133,7 +134,9 @@ class GSFile } return $response; } else { - throw new ServerException(_m('This attachment is not stored locally.')); + // @codeCoverageIgnoreStart + throw new NotStoredLocallyException; + // @codeCoverageIgnoreEnd } } diff --git a/src/Util/Exception/NotStoredLocallyException.php b/src/Util/Exception/NotStoredLocallyException.php new file mode 100644 index 0000000000..a39ff767d3 --- /dev/null +++ b/src/Util/Exception/NotStoredLocallyException.php @@ -0,0 +1,30 @@ +. +// }}} + +namespace App\Util\Exception; + +use function App\Core\I18n\_m; + +class NotStoredLocallyException extends NoSuchFileException +{ + public function __construct() + { + parent::__construct(_m('This attachment is not stored locally')); + } +}