From 7bae8df6fbe8f8d7546d2d009a51a3e6dfca7648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20M=C3=BCller?= Date: Fri, 17 May 2024 12:52:22 +0200 Subject: [PATCH] fix(customwmsbasemapeditor.tsx): catch error when trying to fetch from empty URL string --- src/editor/CustomWMSBasemapEditor.tsx | 48 ++++++++++++--------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/editor/CustomWMSBasemapEditor.tsx b/src/editor/CustomWMSBasemapEditor.tsx index 64c080b..9251ad3 100644 --- a/src/editor/CustomWMSBasemapEditor.tsx +++ b/src/editor/CustomWMSBasemapEditor.tsx @@ -41,33 +41,29 @@ export const CustomWMSBasemapEditor = ({ item, value, onChange, context }: Props // Update the select options when the url changes useEffect(() => { - try { - getWMSCapabilitiesFromService(url!).then(async (node) => { - let layers = getWMSLayers(node); - setOptions(layers); + getWMSCapabilitiesFromService(url!).then(async (node) => { + let layers = getWMSLayers(node); + setOptions(layers); - // If layers are provided because of a repeating entry in edit mode while editing or after refresh - // set the selection to show the user the current layer selection - if (context.options.config && context.options.config.wms.layers) { - let selection_tmp: Array> = []; - - // Generate selection from the available options by comparing the value keys with the layer names of the config - (context.options.config.wms.layers as string[]).forEach( - (el) => { - selection_tmp = selection_tmp.concat( - // User layers since options are update in next render and therefore might be empty - layers.filter((currentValue) => { - return currentValue.value === el; - }) - ); - } - ); - setSelection(selection_tmp); - } - }); - } catch (error) { - - } + // If layers are provided because of a repeating entry in edit mode while editing or after refresh + // set the selection to show the user the current layer selection + if (context.options.config && context.options.config.wms.layers) { + let selection_tmp: Array> = []; + + // Generate selection from the available options by comparing the value keys with the layer names of the config + (context.options.config.wms.layers as string[]).forEach( + (el) => { + selection_tmp = selection_tmp.concat( + // User layers since options are update in next render and therefore might be empty + layers.filter((currentValue) => { + return currentValue.value === el; + }) + ); + } + ); + setSelection(selection_tmp); + } + }).catch(err => {}); // eslint-disable-next-line }, [url]);