[QGIS-Developer] Retrieving error details for when a loaded layer is not valid

Ricardo Filipe Soares Garcia da ricardo.garcia.silva at gmail.com
Fri Nov 26 15:11:36 PST 2021


Hi list

When loading a vector layer via Python, is there a way to get a hold of the
error message for when the loading fails?

I can check if the layer is valid or not, but I'd like to get a description
of the error. I see the error on the QGIS log panel, so I'm hoping it is
possible to access it from Python.

```
# a sample of my code
layer = QgsVectorLayer("some-bogus-url", "mylayer", "WFS")
layer.isValid()  # this returns False
```

Thanks in advance!

-- 
___________________________ ___ __
Ricardo Garcia Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20211126/b9f10df3/attachment.html>


More information about the QGIS-Developer mailing list