Skip to content

Commit c620c7c

Browse files
committedMay 13, 2017
[processing] stop algorithm execution if geometry/feature error occured
(fix #11986)
1 parent 75e9502 commit c620c7c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
 

‎python/plugins/processing/algs/qgis/Intersection.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
QgsMessageLog,
3737
QgsProcessingUtils)
3838

39+
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
3940
from processing.core.GeoAlgorithm import GeoAlgorithm
4041
from processing.core.parameters import ParameterVector
4142
from processing.core.outputs import OutputVector
@@ -114,9 +115,10 @@ def processAlgorithm(self, context, feedback):
114115
int_sym = geom.symDifference(tmpGeom)
115116
int_geom = QgsGeometry(int_com.difference(int_sym))
116117
if int_geom.isEmpty() or not int_geom.isGeosValid():
117-
QgsMessageLog.logMessage(self.tr('GEOS geoprocessing error: One or '
118-
'more input features have invalid '
119-
'geometry.'), self.tr('Processing'), QgsMessageLog.CRITICAL)
118+
raise GeoAlgorithmExecutionException(
119+
self.tr('GEOS geoprocessing error: One or '
120+
'more input features have invalid '
121+
'geometry.'))
120122
try:
121123
if int_geom.wkbType() in wkbTypeGroups[wkbTypeGroups[int_geom.wkbType()]]:
122124
outFeat.setGeometry(int_geom)
@@ -126,7 +128,9 @@ def processAlgorithm(self, context, feedback):
126128
outFeat.setAttributes(attrs)
127129
writer.addFeature(outFeat)
128130
except:
129-
QgsMessageLog.logMessage(self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'), self.tr('Processing'), QgsMessageLog.INFO)
130-
continue
131+
raise GeoAlgorithmExecutionException(
132+
self.tr('Feature geometry error: One or more '
133+
'output features ignored due to invalid '
134+
'geometry.'))
131135

132136
del writer

0 commit comments

Comments
 (0)
Please sign in to comment.