Skip to content

Commit

Permalink
QGIS: don't crash on unknown layers in database (#1265)
Browse files Browse the repository at this point in the history
Currently both Ribasim Python and the core silently ignore extra unknown
tables. This makes QGIS do the same.

```
An error has occurred while executing Python code: 

KeyError: 'Basin / boundaryconcentration' 
Traceback (most recent call last):
  File "C:\Users/visser_mn/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ribasim_qgis\widgets\dataset_widget.py", line 286, in open_model
    self.load_geopackage()
  File "C:\Users/visser_mn/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ribasim_qgis\widgets\dataset_widget.py", line 221, in load_geopackage
    nodes = load_nodes_from_geopackage(geo_path)
  File "C:\Users/visser_mn/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ribasim_qgis\core\nodes.py", line 870, in load_nodes_from_geopackage
    nodes[layername] = NODES[layername](path)
KeyError: 'Basin / boundaryconcentration'
```

---------

Co-authored-by: Maarten Pronk <[email protected]>
  • Loading branch information
visr and evetion authored Mar 14, 2024
1 parent d49febc commit 6bf9312
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ribasim_qgis/core/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,5 +867,7 @@ def load_nodes_from_geopackage(path: Path) -> dict[str, Input]:
gpkg_names = geopackage.layers(path)
nodes = {}
for layername in gpkg_names:
nodes[layername] = NODES[layername](path)
klass = NODES.get(layername)
if klass is not None:
nodes[layername] = klass(path)
return nodes

0 comments on commit 6bf9312

Please sign in to comment.