Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Translatable annotations: Reduce RuntimeException to log message? #14

Open
MalteWunsch opened this issue Feb 9, 2022 · 1 comment

Comments

@MalteWunsch
Copy link
Member

The RuntimeException thrown in

throw new RuntimeException('No translatable attributes annotated with @Polyglot\Translatable were found');
seem to harsh to me.

Sometimes I want to deploy some preparation for translations (namely the *Translatable entity and it's migration) early, so that the migration is executed in the production database and clients can start translating content, before the code is fully functioning. When I do the preparation lazily, I might add @Polyglot\Locale at the class level, but miss to @Polyglot\Translatable at the appripriate attributes - and don't think twice about it, as I know the code does not need to work right now. This results in the RuntimeException.

Having missed adding an annotation is nothing I would expect to result in a RuntimeException. If there are no appropriate tests, this might slip through into production.

Hence I think about reducing this RuntimeException to a log message. If I don't get a translation as expected, the logs might be one of the last places I would look at, but the entity attribute or the README instructions of this bundle seem to be reasonable as first points of contact, so this might be enough?

WDYT, @mpdude @FabianSchmick ?

@FabianSchmick
Copy link
Member

I do understand your valid case and would also log the message instead of throwing an Exception. To hint this in the README should also be done as you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants