Skip to content
Permalink
Browse files
Add QgsProcessingAlgorithm::writeFeatureError() to help throw process…
…ing exception when addFeature() fails
  • Loading branch information
rouault authored and nyalldawson committed Jul 21, 2021
1 parent 5b316fd commit da41d49c53dcc78c4d6f92109f12878d0103cafa
@@ -1025,6 +1025,19 @@ should correspond to the invalid source parameter name.
.. seealso:: :py:func:`invalidRasterError`

.. versionadded:: 3.2
%End

static QString writeFeatureError( QgsFeatureSink *sink, const QVariantMap &parameters, const QString &name );
%Docstring
Returns a user-friendly string to use as an error when a feature cannot be
written into a sink.

The ``sink`` argument is the sink into which the feature cannot be written.

The ``parameters`` argument should give the algorithms parameter map, and the ``name``
should correspond to the sink parameter name.

.. versionadded:: 3.22
%End

virtual bool supportInPlaceEdit( const QgsMapLayer *layer ) const;
@@ -876,6 +876,16 @@ QString QgsProcessingAlgorithm::invalidSinkError( const QVariantMap &parameters,
}
}

QString QgsProcessingAlgorithm::writeFeatureError( QgsFeatureSink *sink, const QVariantMap &parameters, const QString &name )
{
Q_UNUSED( sink );
Q_UNUSED( parameters );
if ( !name.isEmpty() )
return QObject::tr( "Could not write feature into %1" ).arg( name );
else
return QObject::tr( "Could not write feature" );
}

bool QgsProcessingAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
{
Q_UNUSED( layer )
@@ -1022,6 +1022,19 @@ class CORE_EXPORT QgsProcessingAlgorithm
*/
static QString invalidSinkError( const QVariantMap &parameters, const QString &name );

/**
* Returns a user-friendly string to use as an error when a feature cannot be
* written into a sink.
*
* The \a sink argument is the sink into which the feature cannot be written.
*
* The \a parameters argument should give the algorithms parameter map, and the \a name
* should correspond to the sink parameter name.
*
* \since QGIS 3.22
*/
static QString writeFeatureError( QgsFeatureSink *sink, const QVariantMap &parameters, const QString &name );

/**
* Checks whether this algorithm supports in-place editing on the given \a layer
* Default implementation returns FALSE.

0 comments on commit da41d49

Please sign in to comment.