diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-11-16 12:04:34 +0100 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-11-16 12:04:34 +0100 |
commit | 9a705e911485af200937ed4fbbd216f1ecefdea2 (patch) | |
tree | 9078c143b86371040edd02ec814a389d4ad7b86c /pdf-over-commons/src | |
parent | d649500a3e150f38d1ce00277549604f0762f125 (diff) | |
download | pdf-over-9a705e911485af200937ed4fbbd216f1ecefdea2.tar.gz pdf-over-9a705e911485af200937ed4fbbd216f1ecefdea2.tar.bz2 pdf-over-9a705e911485af200937ed4fbbd216f1ecefdea2.zip |
explicit error messages for http non-200
cf. #133
Diffstat (limited to 'pdf-over-commons/src')
-rw-r--r-- | pdf-over-commons/src/main/java/at/asit/pdfover/commons/Messages.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Messages.java b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Messages.java index 04c8583a..d8f204ea 100644 --- a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Messages.java +++ b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Messages.java @@ -27,6 +27,8 @@ import javax.annotation.Nonnull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static at.asit.pdfover.commons.Constants.ISNOTNULL; + /** * Localizes string messages for PDFOver GUI @@ -57,7 +59,7 @@ public class Messages { if (l.equals(ld) || l.getLanguage().equals(ld.getLanguage())) return l; } - return Constants.ISNOTNULL(Constants.SUPPORTED_LOCALES[0]); + return ISNOTNULL(Constants.SUPPORTED_LOCALES[0]); } /** @@ -94,7 +96,7 @@ public class Messages { * @param key * @return the localized message */ - public static String getString(String key) { + public static @Nonnull String getString(String key) { return getString(key, currentLocale); } @@ -104,9 +106,9 @@ public class Messages { * @param locale the locale to use * @return the localized message */ - public static String getString(String key, Locale locale) { + public static @Nonnull String getString(String key, Locale locale) { try { - String value = getBundle(locale).getString(key); + String value = ISNOTNULL(getBundle(locale).getString(key)); /* DIRTY HACK: this recognizes java 8 ("1.8") and older; these versions read .properties files as ISO-8859-1 instead of UTF-8 */ if (System.getProperty("java.version").startsWith("1.")) @@ -118,4 +120,8 @@ public class Messages { return '!' + key + '!'; } } + + public static @Nonnull String formatString(String key, Object... values) { + return ISNOTNULL(String.format(getString(key), values)); + } } |