IMDGMessageResolver добавил номер ошибки в текст
This commit is contained in:
parent
29b7bd7f38
commit
329e2dda28
2 changed files with 5 additions and 4 deletions
|
|
@ -28,12 +28,13 @@ public class IMDGMessageResolver implements IMessageResolver {
|
|||
if (errMsg == null) return "null";
|
||||
Supplier<String> simplFormatter = () -> String.format("(%d) args %s", errMsg.getSubject().getId(), Arrays.toString(errMsg.getArgs()));
|
||||
try {
|
||||
ErrorCodeDictionary errorDictionary = errorCodeDictionaryIMDG.getSingleObjectByID(errMsg.getSubject().getId());
|
||||
Long errId = errMsg.getSubject().getId();
|
||||
ErrorCodeDictionary errorDictionary = errorCodeDictionaryIMDG.getSingleObjectByID(errId);
|
||||
if (errorDictionary == null) {
|
||||
log.warn("ERROR_CODE_DICTIONARY not found for id={}", errMsg.getSubject().getId());
|
||||
return simplFormatter.get();
|
||||
}
|
||||
String textTemplate = errorDictionary.getName();
|
||||
String textTemplate = errId + " " + errorDictionary.getName();
|
||||
return String.format(textTemplate, errMsg.getArgs());
|
||||
} catch (Exception errFormatting) { // MissingFormatArgumentException
|
||||
log.warn("Error in message resolver for error {} id {}. Format error: {}", errMsg.getSubject(), errMsg.getSubject().getId(), errFormatting);
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ class IMDGMessageResolverTest {
|
|||
IErrorEnumId err1 = ClearingErrorInternalTest.TestError;
|
||||
{
|
||||
String text = resolver.resolve(new EnumMessage(err1, "a", "and", "b"));
|
||||
assertEquals("Error 1 test. Two arg a, and.", text);
|
||||
assertEquals("1 Error 1 test. Two arg a, and.", text);
|
||||
}
|
||||
{
|
||||
String text = resolver.resolve(new EnumMessage(err1, "a", "and"));
|
||||
assertEquals("Error 1 test. Two arg a, and.", text);
|
||||
assertEquals("1 Error 1 test. Two arg a, and.", text);
|
||||
}
|
||||
{
|
||||
String text = resolver.resolve(new EnumMessage(err1, "one only this"));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue