In QGIS 2.18.16, with a custom plugin, I tried this code to create a new vector layer for WFS:

v_layer = QgsVectorLayer(uri.uri(), "my WFS layer", "WFS", False)
if not v_layer.isValid():
    print v_layer.error()            # 1
    print v_layer.error().message()  # 2
    print v_layer.error().summary()  # 3
  • print 1: is a qgis._core.QgsError object
  • print 2: empty string
  • print 3: qgis crash with segmentation fault

I need to get an error type or the WFS response to understand, for example, if the url is not correct or if the service is down.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.