diff --git a/src/gm3/application.js b/src/gm3/application.js index dde91d41..f243fe40 100644 --- a/src/gm3/application.js +++ b/src/gm3/application.js @@ -348,6 +348,13 @@ class Application { let mapbookXml = contents; if (typeof contents === "string") { mapbookXml = new DOMParser().parseFromString(contents, "text/xml"); + if (mapbookXml.documentElement.nodeName === "parsererror") { + console.error( + "Could not parse mapbook!", + mapbookXml.documentElement.innerHTML + ); + return false; + } } this.configureSelectionLayer( diff --git a/src/gm3/reducers/mapSource.js b/src/gm3/reducers/mapSource.js index 72e0a881..5f907534 100644 --- a/src/gm3/reducers/mapSource.js +++ b/src/gm3/reducers/mapSource.js @@ -82,14 +82,18 @@ const reducer = createReducer( state, { payload: { mapSourceName, layerName, on } } ) => { - state[mapSourceName].layers = modifyLayer( - state[mapSourceName].layers, - layerName, - (layer) => { - layer.on = on; - return layer; - } - ); + if (!state[mapSourceName]) { + console.error("Map source does not exist: ", mapSourceName); + } else { + state[mapSourceName].layers = modifyLayer( + state[mapSourceName].layers, + layerName, + (layer) => { + layer.on = on; + return layer; + } + ); + } }, [favoriteLayer]: ( state, @@ -104,6 +108,8 @@ const reducer = createReducer( return layer; } ); + } else { + console.error("Map source does not exist: ", mapSourceName); } }, [setLayerTemplate]: (