Fix display error message
This commit is contained in:
parent
8cdd640132
commit
01c6597129
@ -1,5 +1,6 @@
|
|||||||
package jscl.text;
|
package jscl.text;
|
||||||
|
|
||||||
|
import org.solovyev.common.msg.AbstractMessage;
|
||||||
import org.solovyev.common.msg.Message;
|
import org.solovyev.common.msg.Message;
|
||||||
import org.solovyev.common.msg.MessageLevel;
|
import org.solovyev.common.msg.MessageLevel;
|
||||||
import org.solovyev.common.msg.MessageType;
|
import org.solovyev.common.msg.MessageType;
|
||||||
@ -55,7 +56,7 @@ public class ParseException extends Exception implements Message {
|
|||||||
@Override
|
@Override
|
||||||
public String getLocalizedMessage(@Nonnull Locale locale) {
|
public String getLocalizedMessage(@Nonnull Locale locale) {
|
||||||
final ResourceBundle rb = ResourceBundle.getBundle("jscl/text/msg/messages", locale);
|
final ResourceBundle rb = ResourceBundle.getBundle("jscl/text/msg/messages", locale);
|
||||||
return rb.getString(getMessageCode());
|
return AbstractMessage.makeMessage(locale, rb.getString(getMessageCode()), parameters, MessageType.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
|
@ -118,14 +118,16 @@ public abstract class AbstractMessage implements Message {
|
|||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getLocalizedMessage(@Nonnull Locale locale) {
|
public String getLocalizedMessage(@Nonnull Locale locale) {
|
||||||
String result = null;
|
return makeMessage(locale, getMessagePattern(locale), parameters, messageLevel);
|
||||||
|
}
|
||||||
|
|
||||||
final String messagePattern = getMessagePattern(locale);
|
@Nonnull
|
||||||
if (!Strings.isEmpty(messagePattern)) {
|
public static String makeMessage(@Nonnull Locale locale, @Nullable String format, @Nonnull List<?> parameters, @Nonnull MessageLevel messageLevel) {
|
||||||
result = Messages.prepareMessage(locale, messagePattern, parameters);
|
if (!Strings.isEmpty(format)) {
|
||||||
|
return Messages.prepareMessage(locale, format, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Strings.getNotEmpty(result, messageLevel.getName() + ": message code = " + messageCode);
|
return messageLevel.getName() + ": message code = " + format;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
Loading…
Reference in New Issue
Block a user