Skip to content

Commit

Permalink
Merge pull request 3liz#3995 from rldhont/fix-js-catch-getlegendgraph…
Browse files Browse the repository at this point in the history
…ic-error

Bugfix JS: Catch error from GetLegendGraphics
  • Loading branch information
rldhont authored Dec 1, 2023
2 parents 72cf592 + a7450b4 commit a2f88c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion assets/src/modules/WMS.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default class WMS {
...options
})
});
return response.json();
if (response.ok) {
return response.json();
}
throw new Error(response.text);
}
}
13 changes: 7 additions & 6 deletions assets/src/modules/action/Symbology.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ export async function updateLayerTreeLayersSymbology(treeLayers) {
STYLES: wmsStyles,
};

const response = await wms.getLegendGraphic(wmsParams);
for (const node of response.nodes) {
// If the layer has no symbology, there is no type property
if (node.hasOwnProperty('type')) {
treeLayersByName[node.name].symbology = node;
await wms.getLegendGraphic(wmsParams).then((response) => {
for (const node of response.nodes) {
// If the layer has no symbology, there is no type property
if (node.hasOwnProperty('type')) {
treeLayersByName[node.name].symbology = node;
}
}
}
}).catch(console.error);
return treeLayers;
}

Expand Down

0 comments on commit a2f88c5

Please sign in to comment.