Closed palagdan closed 1 month ago
@blcham I can't localize all the errors from the backend because many errors are dynamically generated. So, I replaced only errors with plain text, that does not contains some value from the backend.
@blcham
When we optimize the text there will be grammar issues and it will be harder to maintain by translators.
Variant 2 is nice as it is compact but we should consider that it will be needed to refactor error codes for generic entity errors and also introduce a entity type argument in responseUtis.handleServerError
.
ad 1)
When we optimize the text there will be grammar issues and it will be harder to maintain by translators.
I was not able to find any grammar issue although i do not like it much either.
ad 2)
we can discuss on the meeting.
@blcham
I wanted to discuss one more thing. How should we handle dynamic exception messages like the following with messageId:
public class EntityNotFoundException extends FtaFmeaException {
public EntityNotFoundException(String message) {
super(message);
}
public static EntityNotFoundException create(String resourceName, Object identifier) {
return new EntityNotFoundException(resourceName + " identified by " + identifier + " not found.");
}
}
@palagdan @blcham Idea for question in comment The server can send the arguments for a parametrized error message. For example:
public class ErrorInfo {
private String message;
private String messageId;
private Map<String, String> messageArguments;
private String requestUri;
}
For the example above, consider that server sends messageArguments as follows:
{
resourceName: "Component"
identifier: "component-id"
}
Message template can be declared as follows
"errorId": " {{resourceName}} identified by {{identifier}} not found."
And specific message can be constructed as:
t(data.messageId, data.messageArguments)
Resolves partially #550