<div dir="ltr">Hi Ricardo,<div><br></div><div>have you tried increasing the debug level? I often raise it at 9 using the QGIS_DEBUG env var.</div><div>From a quick look at the source code of QgsVectorLayer <a href="https://github.com/qgis/QGIS/blob/master/src/core/vector/qgsvectorlayer.cpp#L1788-L1806">two cases where the valid flag is set to false</a> are when there are problems with the provider, and this is logged with level 2.</div><div><br></div><div>Giovanni</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno sab 27 nov 2021 alle ore 00:11 Ricardo Filipe Soares Garcia da <<a href="mailto:ricardo.garcia.silva@gmail.com">ricardo.garcia.silva@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi list</div><div><br></div><div>When loading a vector layer via Python, is there a way to get a hold of the error message for when the loading fails?</div><div><br></div><div>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.</div><div><br></div><div>```</div><div># a sample of my code</div><div>layer = QgsVectorLayer("some-bogus-url", "mylayer", "WFS")</div><div>layer.isValid()  # this returns False</div><div>```</div><div><br></div><div>Thanks in advance!<br></div><div><br>-- <br><div dir="ltr">___________________________ ___ __<br>Ricardo Garcia Silva</div></div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>