[EXCEPTION] Fix exceptions not being translated

This commit is contained in:
Hugo Sales 2020-09-04 18:46:12 +00:00 committed by Hugo Sales
parent 7b467091d6
commit 736fb672a5
10 changed files with 35 additions and 17 deletions

View File

@ -37,6 +37,7 @@ use App\Core\Router\Router;
use App\Core\Security;
use App\Entity\GSActor;
use App\Entity\LocalUser;
use App\Util\Exception\NoLoggedInUser;
use Exception;
use Functional as F;

View File

@ -35,6 +35,7 @@
namespace App\Util\Exception;
use function App\Core\I18n\_m;
use Exception;
class ClientException extends Exception
@ -45,6 +46,6 @@ class ClientException extends Exception
}
public function __toString()
{
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
return __CLASS__ . " [{$this->code}]: " . _m($this->message) . "\n";
}
}

View File

@ -17,8 +17,6 @@
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace App\Util\Exception;
/**
* Nickname empty exception
*
@ -38,6 +36,11 @@ namespace App\Util\Exception;
* @copyright 2018-2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Util\Exception;
use function App\Core\I18n\_m;
class NicknameEmptyException extends NicknameInvalidException
{
protected function defaultMessage(): string

View File

@ -17,8 +17,6 @@
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace App\Util\Exception;
/**
* Nickname empty exception
*
@ -38,6 +36,9 @@ namespace App\Util\Exception;
* @copyright 2018-2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Util\Exception;
class NicknameException extends ClientException
{
public function __construct(string $msg = null, int $code = 400)

View File

@ -17,8 +17,6 @@
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace App\Util\Exception;
/**
* Nickname invalid exception
*
@ -38,6 +36,11 @@ namespace App\Util\Exception;
* @copyright 2018-2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Util\Exception;
use function App\Core\I18n\_m;
class NicknameInvalidException extends NicknameException
{
protected function defaultMessage(): string

View File

@ -17,8 +17,6 @@
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace App\Util\Exception;
/**
* Nickname reserved exception
*
@ -38,6 +36,11 @@ namespace App\Util\Exception;
* @copyright 2018-2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Util\Exception;
use function App\Core\I18n\_m;
class NicknameReservedException extends NicknameException
{
protected function defaultMessage(): string

View File

@ -19,8 +19,6 @@
// }}}
namespace App\Util\Exception;
/**
* Nickname empty exception
*
@ -40,6 +38,11 @@ namespace App\Util\Exception;
* @copyright 2018-2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Util\Exception;
use function App\Core\I18n\_m;
class NicknameTakenException extends NicknameException
{
public ?Profile $profile = null; // the Profile which occupies the nickname

View File

@ -19,10 +19,6 @@
// }}}
namespace App\Util\Exception;
use App\Util\Nickname;
/**
* Nickname too long exception
*
@ -42,6 +38,12 @@ use App\Util\Nickname;
* @copyright 2018-2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\Util\Exception;
use function App\Core\I18n\_m;
use App\Util\Nickname;
class NicknameTooLongException extends NicknameInvalidException
{
protected function defaultMessage(): string

View File

@ -29,6 +29,6 @@ namespace App\Util\Exception;
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class NoLoggedInUser extends NicknameInvalidException
class NoLoggedInUser extends ClientException
{
}

View File

@ -38,6 +38,7 @@
namespace App\Util\Exception;
use function App\Core\I18n\_m;
use Exception;
class ServerException extends Exception
@ -49,6 +50,6 @@ class ServerException extends Exception
public function __toString()
{
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
return __CLASS__ . " [{$this->code}]: " . _m($this->message) . "\n";
}
}