content = BookLoader.GSON.fromJson(data, ctype); } catch(Exception e) { content = new ContentError(ctype == null ? "Failed to create a page of type \"" + type + "\", perhaps the type is not registered?" : "Failed to create a page of type \"" + type + "\", perhaps the page file \"" + this.data + "\" is missing or invalid?", e); content = BookLoader.getPageType(type).newInstance(); } catch(InstantiationException | IllegalAccessException | NullPointerException e) { content = new ContentError("Failed to create a page of type \"" + type + "\", perhaps the type is not registered?"); content.load(); } catch(Exception e) { content = new ContentError("Failed to load page " + parent.name + "." + name + ".", e); e.printStackTrace();
@Override public void load() { if(name == null) { name = "section" + parent.unnamedSectionCounter++; } name = name.toLowerCase(); if(!data.equals("no-load")) { IResource pagesInfo = source.getResource(source.getResourceLocation(data)); if(pagesInfo != null) { String data = source.resourceToString(pagesInfo); if(!data.isEmpty()) { try { pages = new ArrayList<>(Arrays.asList(BookLoader.GSON.fromJson(data, PageData[].class))); } catch(Exception e) { pages = new ArrayList<>(); PageData pdError = new PageData(true); pdError.name = "errorrenous"; pdError.content = new ContentError("Failed to load section " + name + ".", e); pages.add(pdError); } } } } for(PageData page : pages) { page.parent = this; page.source = source; page.load(); } icon.location = source.getResourceLocation(icon.file, true); }
PageData page = new PageData(true); page.name = "errorenous"; page.content = new ContentError("Failed to load repository " + repo.toString() + ".", e); error.pages.add(page); sections.add(error); PageData page = new PageData(true); page.name = "errorenous"; page.content = new ContentError("Failed to load the book due to an unexpected error.", e); section.pages.add(page); this.sections.add(section);