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 < [email protected]> 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 > [email protected] > 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
_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
