Skip to content

Commit

Permalink
Bugfix JS: Catch error from GetLegendGraphics
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont authored and github-actions[bot] committed Dec 1, 2023
1 parent 0b96416 commit c808677
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 c808677

Please sign in to comment.