[QGIS-Developer] Retrieving error details for when a loaded layer is not valid
G. Allegri
giovanni.allegri at gmail.com
Fri Nov 26 15:48:52 PST 2021
Hi Ricardo,
have you tried increasing the debug level? I often raise it at 9 using
the QGIS_DEBUG env var.
>From a quick look at the source code of QgsVectorLayer two cases where the
valid flag is set to false
<https://github.com/qgis/QGIS/blob/master/src/core/vector/qgsvectorlayer.cpp#L1788-L1806>
are when there are problems with the provider, and this is logged with
level 2.
Giovanni
Il giorno sab 27 nov 2021 alle ore 00:11 Ricardo Filipe Soares Garcia da <
ricardo.garcia.silva at gmail.com> ha scritto:
> 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
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20211127/f9c9d83b/attachment.html>
More information about the QGIS-Developer
mailing list