IMDGMessageResolver removed stack trace
This commit is contained in:
parent
45f51a1b27
commit
0597fe9136
1 changed files with 10 additions and 9 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
package ru.spcex.clearing.util.services;
|
package ru.spcex.clearing.util.services;
|
||||||
|
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import ru.clearing.platform.dictionary.ErrorCodeDictionary;
|
import ru.clearing.platform.dictionary.ErrorCodeDictionary;
|
||||||
|
|
@ -11,6 +10,7 @@ import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Использует ErrorCodeDictionary для расшифровки текста кодов ошибок.
|
* Использует ErrorCodeDictionary для расшифровки текста кодов ошибок.
|
||||||
|
|
@ -24,19 +24,20 @@ public class IMDGMessageResolver implements IMessageResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String resolve(EnumMessage errorMessage) {
|
public String resolve(EnumMessage errMsg) {
|
||||||
if (errorMessage == null) return "null";
|
if (errMsg == null) return "null";
|
||||||
|
Supplier<String> simplFormatter = () -> String.format("(%d) args %s", errMsg.getSubject().getId(), Arrays.toString(errMsg.getArgs()));
|
||||||
try {
|
try {
|
||||||
ErrorCodeDictionary errorDictionary = errorCodeDictionaryIMDG.getSingleObjectByID(errorMessage.getSubject().getId());
|
ErrorCodeDictionary errorDictionary = errorCodeDictionaryIMDG.getSingleObjectByID(errMsg.getSubject().getId());
|
||||||
if (errorDictionary == null) {
|
if (errorDictionary == null) {
|
||||||
log.warn("ERROR_CODE_DICTIONARY not found fo id={}", errorMessage.getSubject().getId());
|
log.warn("ERROR_CODE_DICTIONARY not found fo id={}", errMsg.getSubject().getId());
|
||||||
return String.format("(%d) args %s", errorMessage.getSubject().getId(), Arrays.toString(errorMessage.getArgs()));
|
return simplFormatter.get();
|
||||||
}
|
}
|
||||||
String textTemplate = errorDictionary.getName();
|
String textTemplate = errorDictionary.getName();
|
||||||
return String.format(textTemplate, errorMessage.getArgs());
|
return String.format(textTemplate, errMsg.getArgs());
|
||||||
} catch (Exception errFormatting) { // MissingFormatArgumentException
|
} catch (Exception errFormatting) { // MissingFormatArgumentException
|
||||||
log.warn("Error in message resolver for error {}: {}", errorMessage.getSubject(), ExceptionUtils.getStackTrace(errFormatting));
|
log.warn("Error in message resolver for error {} id {}", errMsg.getSubject(), errMsg.getSubject().getId());
|
||||||
return String.format("(%d) args %s", errorMessage.getSubject().getId(), Arrays.toString(errorMessage.getArgs()));
|
return simplFormatter.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue