Qgis Python Error Handling