X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/e68778f27b18c21c23387d7609d825ab3a192af7..5c398fccc970cf74b857ea5c191b325564f9893f:/src/editor/modules/data/data.js?ds=inline diff --git a/src/editor/modules/data/data.js b/src/editor/modules/data/data.js index 4a9bc72..db17955 100644 --- a/src/editor/modules/data/data.js +++ b/src/editor/modules/data/data.js @@ -2,11 +2,16 @@ define([ 'libs/jquery', './dialog', 'wlxml/wlxml', - 'wlxml/extensions/list/list' -], function($, Dialog, wlxml, listExtension) { + 'wlxml/extensions/list/list', + 'fnpjs/logging/logging', +], function($, Dialog, wlxml, listExtension, logging) { 'use strict'; -/* global gettext */ +/* global gettext, alert */ + +var logger = logging.getLogger('editor.modules.data'), + stubDocument = '
' + gettext('This is an empty document.') + '
'; + return function(sandbox) { @@ -14,7 +19,14 @@ return function(sandbox) { var document_version = sandbox.getBootstrappedData().version; var history = sandbox.getBootstrappedData().history; - var wlxmlDocument = wlxml.WLXMLDocumentFromXML(sandbox.getBootstrappedData().document); + var wlxmlDocument; + try { + wlxmlDocument = wlxml.WLXMLDocumentFromXML(sandbox.getBootstrappedData().document); + } catch(e) { + logger.exception(e); + alert(gettext('This document contains errors and can\'t be loaded. :(')); // TODO + wlxmlDocument = wlxml.WLXMLDocumentFromXML(stubDocument); + } wlxmlDocument.registerExtension(listExtension); sandbox.getPlugins().forEach(function(plugin) {