v0.7.2: added a safety check to string formatting

This commit is contained in:
Evan Debenham 2019-01-31 15:57:20 -05:00
parent 0c0e831015
commit 67d8bb9781

View File

@ -29,6 +29,7 @@ import java.util.Arrays;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.IllegalFormatException;
import java.util.Locale; import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -146,7 +147,12 @@ public class Messages {
*/ */
public static String format( String format, Object...args ) { public static String format( String format, Object...args ) {
return String.format( Locale.ENGLISH, format, args ); try {
return String.format(Locale.ENGLISH, format, args);
} catch (IllegalFormatException e) {
ShatteredPixelDungeon.reportException( e );
return format;
}
} }
public static String capitalize( String str ){ public static String capitalize( String str ){