[Books] Made the book errors more verbose

- Added short stack trace to error page
- Added stack trace print where it was missing
- Made text data renderer check for null text data
This commit is contained in:
Arthur Uzulin committed 2018-08-17 02:29:51 +10:00
1 parent 35e592fc1c
commit 7bcd1043ba
4 files changed
+24 -3

No files matched your search

@@ -74,6 +74,8 @@ public class BookData implements IDataItem {
page.content = new ContentError("Failed to load repository " + repo.toString() + ".", e);
error.pages.add(page);
sections.add(error);
e.printStackTrace();
}
ResourceLocation appearanceLocation = repo.getResourceLocation("appearance.json");
@@ -65,6 +65,8 @@ public class SectionData implements IDataItem {
pdError.name = "errorrenous";
pdError.content = new ContentError("Failed to load section " + name + ".", e);
pages.add(pdError);
e.printStackTrace();
}
}
}
@@ -30,13 +30,19 @@ public class ContentError extends PageContent {
public void build(BookData book, ArrayList<BookElement> list, boolean rightSide) {
addTitle(list, "Error");
TextData[] text = new TextData[1 + (exception != null ? 2 : 0)];
StackTraceElement[] stackTrace = null;
if(exception != null){
stackTrace = exception.getStackTrace();
}
TextData[] text = new TextData[1 + (exception != null ? 2 : 0) + (stackTrace != null ? 1 + Math.min(stackTrace.length * 2, 8) : 0)];
text[0] = new TextData(errorStage);
text[0].color = "dark_red";
text[0].underlined = true;
text[0].paragraph = true;
if(exception != null) {
text[1] = new TextData("The following error has occured: ");
text[1] = new TextData("The following error has occured:");
text[1].color = "dark_red";
text[1].paragraph = true;
@@ -46,6 +52,17 @@ public class ContentError extends PageContent {
text[2].paragraph = true;
}
text[3] = TextData.LINEBREAK;
if(stackTrace != null){
for(int i = 0; i < stackTrace.length && 5 + i * 2 < text.length; i++){
text[4 + i * 2] = new TextData(stackTrace[i].toString());
text[4 + i * 2].text += "\n";
text[4 + i * 2].color = "dark_red";
text[5 + i * 2] = TextData.LINEBREAK;
}
}
list.add(new ElementText(0, TITLE_HEIGHT, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - TITLE_HEIGHT, text));
}
}
@@ -49,7 +49,7 @@ public class TextDataRenderer {
int box2X, box2Y = 9999, box2W, box2H;
int box3X = 9999, box3Y = 9999, box3W, box3H;
if(item.text == null || item.text.isEmpty()) {
if(item == null || item.text == null || item.text.isEmpty()) {
continue;
}
if(item.text.equals("\n")) {