Added fail-safe

pull/214/head
M66B 10 months ago
parent 2fb0edb782
commit 1db2a69265

@ -41,20 +41,27 @@ public class StructuredEmail {
} }
public String getHtml(Context context) throws JSONException { public String getHtml(Context context) throws JSONException {
StringBuilder sb = new StringBuilder(); try {
getHtml(jroot, 0, sb); StringBuilder sb = new StringBuilder();
getHtml(jroot, 0, sb);
Document d = Document.createShell("");
d.appendElement("hr"); Document d = Document.createShell("");
d.appendElement("div") d.body().appendElement("hr");
.attr("style", "font-size: larger !important;") d.body().appendElement("div")
.text("Linked Data"); .attr("style", "font-size: larger !important;")
d.appendElement("br"); .text("Linked Data");
d.appendElement("div") d.body().appendElement("br");
.attr("style", "font-size: smaller !important;") d.body().appendElement("div")
.html(HtmlHelper.formatPlainText(sb.toString())); .attr("style", "font-size: smaller !important;")
d.appendElement("hr"); .html(HtmlHelper.formatPlainText(sb.toString()));
return d.html(); d.body().appendElement("hr");
return d.body().html();
} catch (Throwable ex) {
Log.e(ex);
Document d = Document.createShell("");
d.body().append("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