forked from GNUsocial/gnu-social
[EXCEPTION] Fix exceptions not being translated
This commit is contained in:
parent
7b467091d6
commit
736fb672a5
@ -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;
|
||||
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user