Skip to content
Permalink
Browse files

Indicate exception types to sip

Exposes the full Python exception when an error occurs in createInstance()
  • Loading branch information
nyalldawson committed Feb 20, 2019
1 parent 03cc355 commit 979adbbabfb467594b9bc373580c0fc308ea6442
@@ -63,7 +63,7 @@ a pre-initialized copy of the algorithm.



QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const /TransferBack/;
QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const throw( QgsProcessingException ) /TransferBack/;
%Docstring
Creates a copy of the algorithm, ready for execution.

@@ -76,6 +76,9 @@ and outputs according to this configuration. This is generally used only for
algorithms in a model, allowing them to adjust their behavior at run time
according to some user configuration.

Raises a QgsProcessingException if a new algorithm instance could not be created,
e.g. if there is an issue with the subclass' createInstance() method.

.. seealso:: :py:func:`initAlgorithm`
%End

@@ -401,7 +404,7 @@ Associates this algorithm with its provider. No transfer of ownership is involve

protected:

virtual QgsProcessingAlgorithm *createInstance() const = 0 /Factory/;
virtual QgsProcessingAlgorithm *createInstance() const = 0 /Factory,VirtualErrorHandler=processing_exception_handler/;
%Docstring
Creates a new instance of the algorithm class.

@@ -122,9 +122,12 @@ class CORE_EXPORT QgsProcessingAlgorithm
* algorithms in a model, allowing them to adjust their behavior at run time
* according to some user configuration.
*
* Raises a QgsProcessingException if a new algorithm instance could not be created,
* e.g. if there is an issue with the subclass' createInstance() method.
*
* \see initAlgorithm()
*/
QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const SIP_TRANSFERBACK;
QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const SIP_THROW( QgsProcessingException ) SIP_TRANSFERBACK;

/**
* Returns the algorithm name, used for identifying the algorithm. This string
@@ -409,7 +412,7 @@ class CORE_EXPORT QgsProcessingAlgorithm
*
* This method should return a 'pristine' instance of the algorithm class.
*/
virtual QgsProcessingAlgorithm *createInstance() const = 0 SIP_FACTORY;
virtual QgsProcessingAlgorithm *createInstance() const = 0 SIP_FACTORY SIP_VIRTUALERRORHANDLER( processing_exception_handler );

/**
* Initializes the algorithm using the specified \a configuration.
@@ -103,7 +103,7 @@ def test_bad_script_dont_crash(self): # spellok

task = QgsProcessingAlgRunnerTask(CrashingProcessingAlgorithm(), {}, context=context, feedback=feedback)
self.assertTrue(task.isCanceled())
self.assertEqual(feedback._error, 'Error creating algorithm from createInstance()')
self.assertIn('name \'ExampleProcessingAlgorithm\' is not defined', feedback._error)


if __name__ == '__main__':

0 comments on commit 979adbb

Please sign in to comment.
You can’t perform that action at this time.