X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FGigiApiException.java;h=0d600b973f3284fa17fe8861e51398148b9aa448;hb=084ba501e5879a03c74853b6b566841e5c152726;hp=944fe645ece5618fb2dc93afc5318d164be6c84b;hpb=ec24cf6925bb3729a644580ad4a9375d05883c62;p=gigi.git diff --git a/src/org/cacert/gigi/GigiApiException.java b/src/org/cacert/gigi/GigiApiException.java index 944fe645..0d600b97 100644 --- a/src/org/cacert/gigi/GigiApiException.java +++ b/src/org/cacert/gigi/GigiApiException.java @@ -13,6 +13,8 @@ import org.cacert.gigi.output.template.TranslateCommand; public class GigiApiException extends Exception { + private static final Language PLAIN_LANGUAGE = Language.getInstance(Locale.ENGLISH); + private static final long serialVersionUID = -164928670180852588L; private SQLException e; @@ -53,7 +55,7 @@ public class GigiApiException extends Exception { if (isInternalError()) { e.printStackTrace(); out.print("
"); - out.println(language.getTranslation("An internal error ouccured.")); + out.println(language.getTranslation("An internal error occurred.")); out.println("
"); } HashMap map = new HashMap<>(); @@ -68,6 +70,24 @@ public class GigiApiException extends Exception { } + public void formatPlain(PrintWriter out) { + if (isInternalError()) { + out.println(PLAIN_LANGUAGE.getTranslation("An internal error occurred.")); + } + HashMap map = new HashMap<>(); + for (Outputable message : messages) { + if (message instanceof TranslateCommand) { + String m = ((TranslateCommand) message).getRaw(); + // Skip HTML Entities + out.println(PLAIN_LANGUAGE.getTranslation(m)); + } else { + map.clear(); + message.output(out, PLAIN_LANGUAGE, map); + out.println(); + } + } + } + public boolean isEmpty() { return e == null && messages.size() == 0; } @@ -81,7 +101,7 @@ public class GigiApiException extends Exception { HashMap map = new HashMap<>(); for (Outputable message : messages) { map.clear(); - message.output(pw, Language.getInstance(Locale.ENGLISH), map); + message.output(pw, PLAIN_LANGUAGE, map); } pw.flush();