From fe34c45192cffb97caa213e63c0eac4ade43d184 Mon Sep 17 00:00:00 2001 From: viperminiq Date: Tue, 6 May 2025 11:16:55 +0200 Subject: [PATCH] throw exception when trying to add same field name --- src/analysis/processing/qgsalgorithmaddincrementalfield.cpp | 3 +-- src/analysis/processing/qgsalgorithmaddtablefield.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/analysis/processing/qgsalgorithmaddincrementalfield.cpp b/src/analysis/processing/qgsalgorithmaddincrementalfield.cpp index 78229649475..4bd145ae5e0 100644 --- a/src/analysis/processing/qgsalgorithmaddincrementalfield.cpp +++ b/src/analysis/processing/qgsalgorithmaddincrementalfield.cpp @@ -120,8 +120,7 @@ bool QgsAddIncrementalFieldAlgorithm::prepareAlgorithm( const QVariantMap ¶m if ( source->fields().lookupField( mFieldName ) >= 0 ) { - feedback->reportError( QObject::tr( "Field with the same name already exists" ) ); - return false; + throw QgsProcessingException( QObject::tr( "Field with the same name already exists" ) ); } return true; diff --git a/src/analysis/processing/qgsalgorithmaddtablefield.cpp b/src/analysis/processing/qgsalgorithmaddtablefield.cpp index 68ab82283aa..425ed7ff8aa 100644 --- a/src/analysis/processing/qgsalgorithmaddtablefield.cpp +++ b/src/analysis/processing/qgsalgorithmaddtablefield.cpp @@ -131,8 +131,7 @@ bool QgsAddTableFieldAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, if ( source->fields().lookupField( name ) >= 0 ) { - feedback->reportError( QObject::tr( "Field with the same name already exists" ) ); - return false; + throw QgsProcessingException( QObject::tr( "Field with the same name already exists" ) ); } mField.setName( name );