Skip to main content
deleted 1 character in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack())

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the scriptmethod never prints ERROR! ERROR!runs although itthe processing tool throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack())

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the script never prints ERROR! ERROR! although it throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack())

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the method never runs although the processing tool throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

Rollback to Revision 5
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Method 'reportError' in subclass of QgsProcessingFeedback never running

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack()) ```

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR! ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the script never prints ERROR! ERROR! ERROR! ERROR! although it throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

Method 'reportError' in subclass of QgsProcessingFeedback never running

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack()) ```

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR! ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the script never prints ERROR! ERROR! ERROR! ERROR! although it throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

'reportError' in subclass of QgsProcessingFeedback never running

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack())

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the script never prints ERROR! ERROR! although it throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

Tweeted twitter.com/StackGIS/status/1346516819574747140
Rollback to Revision 4
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

Method 'reportError' in subclass of QgsProcessingFeedback never running

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack()) ```

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR! ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the script never prints ERROR! ERROR! ERROR! ERROR! although it throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

'reportError' in subclass of QgsProcessingFeedback never running

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack())

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the script never prints ERROR! ERROR! although it throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

Method 'reportError' in subclass of QgsProcessingFeedback never running

I have two layers, layer_a and layer_b. Both have invalid geometries. When I run a processing tool, it throws an error as expected.

Based on the answer posted here by @ndawson, if you subclass QgsProcessingFeedback, you can implement your own custom logic dealing with the error.

class MyFeedBack(QgsProcessingFeedback):

    def reportError(self, error, fatalError=False):
        print(error)

...

res = processing.run("TOOL_NAME", params, feedback=MyFeedBack()) ```

When I run the following script in QGIS Python Editor

class MyFeedBack(QgsProcessingFeedback): 
    def reportError(self, error, fatalError=False): 
        print("ERROR! ERROR! ERROR! ERROR!")
            
layer_a = QgsProject.instance().mapLayersByName("a")[0]
layer_b = QgsProject.instance().mapLayersByName('b')[0]

feedback = MyFeedBack()

params = {'INPUT': layer_a, 'OVERLAY': layer_b, 'OUTPUT': 'TEMPORARY_OUTPUT'}
rslt = processing.run("native:intersection", params, feedback=feedback)

print("\nDone!")

I get this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 9, in <module>
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 159, in runAlgorithm
    ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
  File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 71, in execute
    results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Feature (0) from “b” has invalid geometry. Please fix the geometry or change the Processing setting to the “Ignore invalid input features” option.

According to documentation, reportError method should run in case of any error. But the script never prints ERROR! ERROR! ERROR! ERROR! although it throws an error.

What am I doing wrong?

I use
QGIS 3.16.2-Hannover, Ubuntu 20.04.1 LTS
QGIS 3.16.0-Hannover, Windows 10 x64

deleted 25 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404
Loading
added 22 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404
Loading
added 6 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404
Loading
added 42 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404
Loading
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404
Loading