[QGIS-Developer] Retrieving error details for when a loaded layer is not valid
Alessandro Pasotti
apasotti at gmail.com
Sat Nov 27 02:19:58 PST 2021
Hi,
you can try with
https://qgis.org/pyqgis/3.0/core/Data/QgsDataProvider.html#qgis.core.QgsDataProvider.error
On Sat, Nov 27, 2021 at 12:11 AM Ricardo Filipe Soares Garcia da <
ricardo.garcia.silva at gmail.com> wrote:
> 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
>
--
Alessandro Pasotti
QCooperative: www.qcooperative.net
ItOpen: www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20211127/7579fd4f/attachment.html>
More information about the QGIS-Developer
mailing list