Skip to content

Commit

Permalink
runPrepared rethrows exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 6, 2017
1 parent 90f10ae commit ebd346c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 13 additions & 8 deletions src/core/processing/qgsprocessingalgorithm.cpp
Expand Up @@ -334,10 +334,17 @@ QVariantMap QgsProcessingAlgorithm::run( const QVariantMap &parameters, QgsProce
if ( !res )
return QVariantMap();

QVariantMap runRes = alg->runPrepared( parameters, context, feedback );

if ( !alg->mHasExecuted )
QVariantMap runRes;
try
{
runRes = alg->runPrepared( parameters, context, feedback );
}
catch ( QgsProcessingException &e )
{
QgsMessageLog::logMessage( e.what(), QObject::tr( "Processing" ), QgsMessageLog::CRITICAL );
feedback->reportError( e.what() );
return QVariantMap();
}

if ( ok )
*ok = true;
Expand Down Expand Up @@ -410,17 +417,15 @@ QVariantMap QgsProcessingAlgorithm::runPrepared( const QVariantMap &parameters,
}
return runResults;
}
catch ( QgsProcessingException &e )
catch ( QgsProcessingException & )
{
QgsMessageLog::logMessage( e.what(), QObject::tr( "Processing" ), QgsMessageLog::CRITICAL );
feedback->reportError( e.what() );

if ( mLocalContext )
{
// see above!
mLocalContext->pushToThread( context.thread() );
}
return QVariantMap();
//rethrow
throw;
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/core/processing/qgsprocessingalgrunnertask.cpp
Expand Up @@ -52,8 +52,10 @@ bool QgsProcessingAlgRunnerTask::run()
mResults = mAlgorithm->runPrepared( mParameters, mContext, mFeedback );
ok = true;
}
catch ( QgsProcessingException & )
catch ( QgsProcessingException &e )
{
QgsMessageLog::logMessage( e.what(), QObject::tr( "Processing" ), QgsMessageLog::CRITICAL );
mFeedback->reportError( e.what() );
return false;
}
return ok && !mFeedback->isCanceled();
Expand Down

0 comments on commit ebd346c

Please sign in to comment.