[UTIL][EXCEPTIONS] Introduce NotStoredLocallyException

This commit is contained in:
Hugo Sales 2021-08-16 17:06:02 +01:00
parent 33bf99cfda
commit fb861ed41f
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 34 additions and 1 deletions

View File

@ -27,6 +27,7 @@ use App\Entity\Attachment;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\DuplicateFoundException; use App\Util\Exception\DuplicateFoundException;
use App\Util\Exception\NoSuchFileException; use App\Util\Exception\NoSuchFileException;
use App\Util\Exception\NotStoredLocallyException;
use App\Util\Exception\NotFoundException; use App\Util\Exception\NotFoundException;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use SplFileInfo; use SplFileInfo;
@ -133,7 +134,9 @@ class GSFile
} }
return $response; return $response;
} else { } else {
throw new ServerException(_m('This attachment is not stored locally.')); // @codeCoverageIgnoreStart
throw new NotStoredLocallyException;
// @codeCoverageIgnoreEnd
} }
} }

View File

@ -0,0 +1,30 @@
<?php
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
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'));
}
}