Added fail-safe

pull/214/head
M66B 2 years ago
parent 0b2f2d81f6
commit 210d8b717b

@ -41,6 +41,7 @@ public class StructuredEmail {
} }
public String getHtml(Context context) throws JSONException { public String getHtml(Context context) throws JSONException {
try {
String title; String title;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -166,16 +167,23 @@ public class StructuredEmail {
} }
Document d = Document.createShell(""); Document d = Document.createShell("");
d.appendElement("hr"); d.body().appendElement("hr");
d.appendElement("div") d.body().appendElement("div")
.attr("style", "font-size: larger !important;") .attr("style", "font-size: larger !important;")
.text(title); .text(title);
d.appendElement("br"); d.body().appendElement("br");
d.appendElement("div") d.body().appendElement("div")
.attr("style", "font-size: smaller !important;") .attr("style", "font-size: smaller !important;")
.html(HtmlHelper.formatPlainText(sb.toString())); .html(HtmlHelper.formatPlainText(sb.toString()));
d.appendElement("hr"); d.body().appendElement("hr");
return d.html(); return d.body().html();
} catch (Throwable ex) {
Log.e(ex);
Document d = Document.createShell("");
d.body().appendElement("pre").text(Log.formatThrowable(ex, false));
return d.body().html();
}
} }
private void getHtml(Object obj, int indent, StringBuilder sb) throws JSONException { private void getHtml(Object obj, int indent, StringBuilder sb) throws JSONException {

Loading…
Cancel
Save