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