mirror of https://github.com/M66B/FairEmail.git
Added fail-safe
This commit is contained in:
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("");
|
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("Linked Data");
|
.text("Linked Data");
|
||||||
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().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…
Reference in New Issue