X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fcacert%2Fgigi%2FGigiApiException.java;h=0d600b973f3284fa17fe8861e51398148b9aa448;hb=11116b080c0d558126f513a528419aba60dd3eea;hp=944fe645ece5618fb2dc93afc5318d164be6c84b;hpb=87c6ea794b343732e32514cba17d047c6fc196a4;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();