Hi all, Translation of Exceptions

dianecrowe04us
Member | 1
+
0
-

A massage chair is a reasonable size investment. While it will pay for itself when compared to a regular visit to the local masseuse, you should be sure that you are buying the best value massage chair possible. A good looking design is important because your new massage chair will almost certainly take pride of place in your living room, but it is also important that you find a chair that offers a good variety of massage styles, varied settings to ensure you get the exact massage you want, and intuitive controls.

Good Looking Design

Massage chairs made from synthetic leather often prove to be the best choice. Real leather may have a uniquely exquisite look to it but the motion of the massage mechanism and the moving parts inside the chair can quickly lead to damage to leather and other materials. High quality synthetic leather is considerably better equipped to be able to cope with the rigours that a massage chair will be put through. A good choice of styles, models, and colours are available to help you select a chair that is perfect for your home.

Last edited by dianecrowe04us (2020-08-31 04:18)

jiri.pudil
Member | 933
+
+9
-

Hello and welcome!

I don't think it's a good idea to translate exception messages directly – they are meant for the developer, not for the user. You can use the exception code to distinguish different authentication failures and get the right translation key, e.g. like this:

try {
    $authenticator->authenticate(...$credentials);
} catch (AuthenticationException $e) {
    switch ($e->getCode()) {
        case IAuthenticator::IDENTITY_NOT_FOUND:
            $message = 'authentication.error.userNotFound'; break;
        case IAuthenticator::INVALID_CREDENTIAL:
            $message = 'authentication.error.invalidPassword'; break;
        default:
            $message = 'authentication.error.unknownError';
    }

    $this->flashMessage($message, 'error');
}